public IssueTryout() { try { initEmuCardService(); CredentialDescription cd = DescriptionStore.getInstance().getCredentialDescriptionByName("Surfnet", "root"); IdemixSecretKey isk = IdemixKeyStore.getInstance().getSecretKey(cd); // Setup the attributes that will be issued to the card Attributes attributes = new Attributes(); attributes.add("userID", "*****@*****.**".getBytes()); attributes.add("securityHash", "DEADBEEF".getBytes()); // Setup a connection and send pin for emulated card service IdemixService is = new IdemixService(cs); IdemixCredentials ic = new IdemixCredentials(is); ic.connect(); is.sendPin("0000".getBytes()); ic.issue(cd, isk, attributes, null); // null indicates default expiry final Path path = Paths.get(System.getProperty("user.dir"), "card.json"); IRMACardHelper.storeState(card, path); // Setup a connection to a real card // CardService real = new TerminalCardService(); <--- doesn't exist? } catch (Exception e) { e.printStackTrace(); } }
@Override protected Exception doInBackground(Void... voids) { Log.i(TAG, "Loading DescriptionStore and IdemixKeyStore"); FileReader reader = new AndroidFileReader(MainActivity.this); SSLSocketFactory socketFactory = null; if (Build.VERSION.SDK_INT >= 21) // 20 = 4.4 Kitkat, 21 = 5.0 Lollipop socketFactory = new SecureSSLSocketFactory(); try { DescriptionStore.initialize( new DescriptionStoreDeserializer(reader), IRMApp.getStoreManager(), socketFactory); Log.i(TAG, "Loaded DescriptionStore"); publishProgress(); IdemixKeyStore.initialize(new IdemixKeyStoreDeserializer(reader), IRMApp.getStoreManager()); Log.i(TAG, "Loaded IdemixKeyStore"); return null; } catch (InfoException e) { return e; } }
@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); } }); } } }