コード例 #1
0
  protected void tryDeleteCredential(int hashCode) {
    if (getState() != State.IDLE) {
      Log.i(TAG, "Delete long-click ignored in non-idle mode");
      return;
    }

    IdemixCredentialIdentifier ici = CredentialManager.findCredential(hashCode);
    if (ici == null) return;

    Log.w(TAG, "Deleting credential " + ici.toString());
    CredentialManager.delete(ici);
    updateCredentialList();
  }
コード例 #2
0
 @Override
 protected Exception doInBackground(Void... params) {
   try {
     Log.i(TAG, "Loading credentials and logs");
     CredentialManager.init(settings);
     return null;
   } catch (CredentialsException e) {
     return e;
   }
 }
コード例 #3
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   Log.d(TAG, "menu press registered");
   // Handle item selection
   switch (item.getItemId()) {
     case R.id.preferences:
       Intent intent = new Intent();
       intent.setClassName(this, IRMAPreferenceActivity.class.getName());
       startActivityForResult(intent, IRMAPreferenceActivity.ACTIVITY_CODE);
       return true;
     case R.id.enroll:
       Log.d(TAG, "enroll menu item pressed");
       onEnrollButtonTouch(null);
       return true;
     case R.id.online_enroll:
       Log.d(TAG, "online enroll menu item pressed");
       onOnlineEnrollButtonTouch(null);
       return true;
     case R.id.show_card_log:
       Log.d(TAG, "show_card_log pressed");
       ArrayList<LogEntry> logs = new ArrayList<>(CredentialManager.getLog());
       logs = new ArrayList<>(logs.subList(0, Math.min(logs.size(), 250)));
       Intent logIntent = new Intent(this, LogActivity.class);
       logIntent.putExtra(LogFragment.ARG_LOG, logs);
       startActivity(logIntent);
       return true;
     case R.id.menu_clear:
       if (getState() == State.IDLE) {
         deleteAllCredentials();
         updateCredentialList();
       }
       return true;
     case R.id.menu_delete_everything:
       CredentialManager.clear();
       updateCredentialList();
       return true;
     case R.id.menu_manual_session:
       startManualSession();
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
コード例 #4
0
  /**
   * Update the list of credentials if the activity is in the appropriate state
   *
   * @param tryDownloading Whether to update the description store and keystore in advance
   */
  protected void updateCredentialList(boolean tryDownloading) {
    if (!credentialsLoaded
        || !descriptionStoreLoaded
        || (!getState().isBooting() && getState() != State.IDLE)) return;

    if (tryDownloading) {
      CredentialManager.updateStores(
          new StoreManager.DownloadHandler() {
            @Override
            public void onSuccess() {
              updateCredentialList(false);
            }

            @Override
            public void onError(Exception e) {
              setFeedback(getString(R.string.downloading_credential_info_failed), "warning");
              updateCredentialList(false);
            }
          });
    }

    LinkedHashMap<IdemixCredentialIdentifier, Attributes> credentials =
        CredentialManager.getAllAttributes();
    credentialListAdapter.updateData(credentials);

    TextView noCredsText = (TextView) findViewById(R.id.no_credentials_text);
    Button enrollButton = (Button) findViewById(R.id.enroll_button);
    Button onlineEnrollButton = (Button) findViewById(R.id.online_enroll_button);
    int visibility = credentials.isEmpty() ? View.VISIBLE : View.INVISIBLE;

    if (noCredsText != null && enrollButton != null) {
      noCredsText.setVisibility(visibility);
      enrollButton.setVisibility(visibility);
      onlineEnrollButton.setVisibility(visibility);
    }
  }
コード例 #5
0
    @Override
    protected void onPostExecute(Exception e) {
      Log.i(TAG, "Finished loading DescriptionStore and IdemixKeyStore");
      if (e != null) throw new RuntimeException(e);
      else setState(State.KEY_STORE_LOADED);

      for (SchemeManager manager : DescriptionStore.getInstance().getSchemeManagers()) {
        if (manager.hasKeyshareServer()
            && !CredentialManager.isEnrolledToKeyshareServer(manager.getName())) {
          final SchemeManager m = manager;
          SchemeManagerHandler.getKeyserverEnrollInput(
              MainActivity.this,
              new SchemeManagerHandler.KeyserverInputHandler() {
                @Override
                public void done(String email, String pin) {
                  SchemeManagerHandler.enrollCloudServer(
                      m.getName(), m.getKeyshareServer(), email, pin, MainActivity.this, null);
                }
              });
        }
      }
    }
コード例 #6
0
 public void onEnrollButtonTouch(View v) {
   Intent i = new Intent(this, EnrollSelectActivity.class);
   CredentialManager.save();
   startActivityForResult(i, EnrollSelectActivity.ACTIVITY_CODE);
 }