Search in sources :

Example 1 with ServerData

use of org.openecard.gui.android.eac.types.ServerData in project open-ecard by ecsec.

the class EacGuiImpl method loadValuesFromSteps.

public void loadValuesFromSteps(Step step1, Step step2) {
    String subject = "", subjectUrl = "";
    TermsOfUsage termsOfUsage = new TermsOfUsage("text/plain", new byte[0]);
    String validity = "";
    String issuer = "", issuerUrl = "";
    for (InputInfoUnit next : step1.getInputInfoUnits()) {
        if ("SubjectName".equals(next.getID()) && next instanceof ToggleText) {
            ToggleText tt = (ToggleText) next;
            subject = tt.getText();
        } else if ("SubjectURL".equals(next.getID()) && next instanceof ToggleText) {
            ToggleText tt = (ToggleText) next;
            subjectUrl = tt.getText();
        } else if ("TermsOfUsage".equals(next.getID()) && next instanceof ToggleText) {
            ToggleText tt = (ToggleText) next;
            Document d = tt.getDocument();
            termsOfUsage = new TermsOfUsage(d.getMimeType(), d.getValue());
        } else if ("Validity".equals(next.getID()) && next instanceof ToggleText) {
            ToggleText tt = (ToggleText) next;
            validity = tt.getText();
        } else if ("IssuerName".equals(next.getID()) && next instanceof ToggleText) {
            ToggleText tt = (ToggleText) next;
            issuer = tt.getText();
        } else if ("IssuerURL".equals(next.getID()) && next instanceof ToggleText) {
            ToggleText tt = (ToggleText) next;
            issuerUrl = tt.getText();
        }
    }
    ArrayList<BoxItem> readAccess = new ArrayList<>();
    ArrayList<BoxItem> writeAccess = new ArrayList<>();
    for (InputInfoUnit next : step2.getInputInfoUnits()) {
        if ("ReadCHATCheckBoxes".equals(next.getID()) && next instanceof Checkbox) {
            Checkbox cb = (Checkbox) next;
            this.readAccessBox = cb;
            for (org.openecard.gui.definition.BoxItem nb : cb.getBoxItems()) {
                BoxItem bi = new BoxItem(nb.getName(), nb.isChecked(), nb.isDisabled(), nb.getText());
                readAccess.add(bi);
            }
        } else if ("WriteCHATCheckBoxes".equals(next.getID()) && next instanceof Checkbox) {
            Checkbox cb = (Checkbox) next;
            this.writeAccessBox = cb;
            for (org.openecard.gui.definition.BoxItem nb : cb.getBoxItems()) {
                BoxItem bi = new BoxItem(nb.getName(), nb.isChecked(), nb.isDisabled(), nb.getText());
                writeAccess.add(bi);
            }
        }
    }
    ServerData sd = new ServerData(subject, subjectUrl, termsOfUsage, validity, issuer, issuerUrl, readAccess, writeAccess);
    serverData.deliver(sd);
}
Also used : TermsOfUsage(org.openecard.gui.android.eac.types.TermsOfUsage) ToggleText(org.openecard.gui.definition.ToggleText) ArrayList(java.util.ArrayList) Document(org.openecard.gui.definition.Document) InputInfoUnit(org.openecard.gui.definition.InputInfoUnit) Checkbox(org.openecard.gui.definition.Checkbox) ServerData(org.openecard.gui.android.eac.types.ServerData) BoxItem(org.openecard.gui.android.eac.types.BoxItem)

Example 2 with ServerData

use of org.openecard.gui.android.eac.types.ServerData in project open-ecard by ecsec.

the class EacGuiImplTest method testPinOkFirstTime.

@Test
public void testPinOkFirstTime() throws InterruptedException {
    new Expectations() {

        {
            eacData.passwordType = "PIN";
            paceMarker.getMinLength();
            result = 6;
            paceMarker.getMaxLength();
            result = 6;
        }
    };
    final GuiIfaceReceiver<EacGuiImpl> guiRec = new GuiIfaceReceiver<>();
    final EacGuiImpl anyGuiImpl = new EacGuiImpl();
    guiRec.setUiInterface(anyGuiImpl);
    Thread t = new Thread(new Runnable() {

        @Override
        public void run() {
            UserConsentDescription uc = new UserConsentDescription("Test");
            uc.getSteps().addAll(createInitialSteps());
            EacNavigator nav = new EacNavigator(uc, guiRec);
            ExecutionEngine exe = new ExecutionEngine(nav);
            exe.process();
        }
    }, "GUI-Executor");
    t.start();
    // use the Binders API to access the values
    ServerData sd = anyGuiImpl.getServerData();
    assertEquals(sd.getSubject(), "Test Subject");
    anyGuiImpl.selectAttributes(sd.getReadAccessAttributes(), sd.getWriteAccessAttributes());
    assertEquals(anyGuiImpl.getPinStatus(), PinStatus.RC3);
    assertTrue(anyGuiImpl.enterPin(null, "123456"));
    // wait for executor to finish
    t.join();
}
Also used : Expectations(mockit.Expectations) ExecutionEngine(org.openecard.gui.executor.ExecutionEngine) GuiIfaceReceiver(org.openecard.gui.android.GuiIfaceReceiver) UserConsentDescription(org.openecard.gui.definition.UserConsentDescription) ServerData(org.openecard.gui.android.eac.types.ServerData) Test(org.testng.annotations.Test)

Aggregations

ServerData (org.openecard.gui.android.eac.types.ServerData)2 ArrayList (java.util.ArrayList)1 Expectations (mockit.Expectations)1 GuiIfaceReceiver (org.openecard.gui.android.GuiIfaceReceiver)1 BoxItem (org.openecard.gui.android.eac.types.BoxItem)1 TermsOfUsage (org.openecard.gui.android.eac.types.TermsOfUsage)1 Checkbox (org.openecard.gui.definition.Checkbox)1 Document (org.openecard.gui.definition.Document)1 InputInfoUnit (org.openecard.gui.definition.InputInfoUnit)1 ToggleText (org.openecard.gui.definition.ToggleText)1 UserConsentDescription (org.openecard.gui.definition.UserConsentDescription)1 ExecutionEngine (org.openecard.gui.executor.ExecutionEngine)1 Test (org.testng.annotations.Test)1