Search in sources :

Example 16 with UserConsentDescription

use of org.openecard.gui.definition.UserConsentDescription 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)

Example 17 with UserConsentDescription

use of org.openecard.gui.definition.UserConsentDescription in project open-ecard by ecsec.

the class UnblockPINDialog method createUserConsentDescription.

private UserConsentDescription createUserConsentDescription() {
    UserConsentDescription uc = new UserConsentDescription(lang.translationForKey(TITLE, AppVersion.getName()));
    uc.getSteps().addAll(createSteps());
    return uc;
}
Also used : UserConsentDescription(org.openecard.gui.definition.UserConsentDescription)

Example 18 with UserConsentDescription

use of org.openecard.gui.definition.UserConsentDescription in project open-ecard by ecsec.

the class TCTokenRequest method findCard.

/**
 * Finds a card which matches one of the give types.
 *
 * @param types String array containing valid card types.
 * @param disp Dispatcher used to query cards and terminals.
 * @param gui User consent to display messages to the user.
 * @return ConnectionHandleType object of the chosen card.
 */
private static ConnectionHandleType findCard(@Nonnull String[] types, @Nonnull Context ctx) throws MissingActivationParameterException, UserCancellationException {
    CardRecognition rec = ctx.getRecognition();
    Map<String, String> namesAndType = new HashMap<>();
    for (String type : types) {
        namesAndType.put(rec.getTranslatedCardName(type), type);
    }
    InsertCardDialog insCardDiag = new InsertCardDialog(ctx.getUserConsent(), ctx.getCardStates(), namesAndType, ctx.getEventDispatcher());
    List<ConnectionHandleType> usableCards = insCardDiag.show();
    if (usableCards == null) {
        // user aborted the card insertion dialog
        throw new UserCancellationException(null, LANG.translationForKey(CARD_INSERTION_ABORT));
    }
    ConnectionHandleType handle;
    if (usableCards.size() > 1) {
        UserConsentDescription ucd = new UserConsentDescription(LANG.translationForKey("card.selection.heading.uc", AppVersion.getName()));
        String stepTitle = LANG.translationForKey("card.selection.heading.step");
        CardSelectionStep step = new CardSelectionStep(stepTitle, usableCards, ctx.getRecognition());
        ArrayList<String> types2 = new ArrayList<>();
        types2.addAll(namesAndType.values());
        CardMonitorTask task = new CardMonitorTask(types2, step);
        ctx.getEventDispatcher().add(task, EventType.CARD_REMOVED, EventType.CARD_RECOGNIZED);
        step.setBackgroundTask(task);
        CardSelectionAction action = new CardSelectionAction(step, usableCards, types2, ctx);
        step.setAction(action);
        ucd.getSteps().add(step);
        UserConsent uc = ctx.getUserConsent();
        UserConsentNavigator ucNav = uc.obtainNavigator(ucd);
        ExecutionEngine exec = new ExecutionEngine(ucNav);
        ResultStatus resStatus = exec.process();
        if (resStatus != ResultStatus.OK) {
            throw new MissingActivationParameterException(CARD_SELECTION_ABORT);
        }
        handle = action.getResult();
        ctx.getEventDispatcher().del(task);
    } else {
        handle = usableCards.get(0);
    }
    return handle;
}
Also used : ConnectionHandleType(iso.std.iso_iec._24727.tech.schema.ConnectionHandleType) HashMap(java.util.HashMap) ResultStatus(org.openecard.gui.ResultStatus) ArrayList(java.util.ArrayList) MissingActivationParameterException(org.openecard.binding.tctoken.ex.MissingActivationParameterException) CardMonitorTask(org.openecard.addons.tr03124.gui.CardMonitorTask) CardSelectionStep(org.openecard.addons.tr03124.gui.CardSelectionStep) UserConsent(org.openecard.gui.UserConsent) UserConsentNavigator(org.openecard.gui.UserConsentNavigator) ExecutionEngine(org.openecard.gui.executor.ExecutionEngine) UserCancellationException(org.openecard.binding.tctoken.ex.UserCancellationException) UserConsentDescription(org.openecard.gui.definition.UserConsentDescription) CardRecognition(org.openecard.common.interfaces.CardRecognition) InsertCardDialog(org.openecard.common.sal.util.InsertCardDialog) CardSelectionAction(org.openecard.addons.tr03124.gui.CardSelectionAction)

Aggregations

UserConsentDescription (org.openecard.gui.definition.UserConsentDescription)18 Step (org.openecard.gui.definition.Step)8 Text (org.openecard.gui.definition.Text)7 ExecutionEngine (org.openecard.gui.executor.ExecutionEngine)6 UserConsentNavigator (org.openecard.gui.UserConsentNavigator)4 ResultStatus (org.openecard.gui.ResultStatus)3 ConnectionHandleType (iso.std.iso_iec._24727.tech.schema.ConnectionHandleType)2 InputAPDUInfoType (iso.std.iso_iec._24727.tech.schema.InputAPDUInfoType)2 Transmit (iso.std.iso_iec._24727.tech.schema.Transmit)2 TransmitResponse (iso.std.iso_iec._24727.tech.schema.TransmitResponse)2 Result (oasis.names.tc.dss._1_0.core.schema.Result)2 CardResponseAPDU (org.openecard.common.apdu.common.CardResponseAPDU)2 UserConsent (org.openecard.gui.UserConsent)2 Test (org.testng.annotations.Test)2 AltVUMessagesType (iso.std.iso_iec._24727.tech.schema.AltVUMessagesType)1 DIDAuthenticate (iso.std.iso_iec._24727.tech.schema.DIDAuthenticate)1 DIDAuthenticateResponse (iso.std.iso_iec._24727.tech.schema.DIDAuthenticateResponse)1 DIDAuthenticationDataType (iso.std.iso_iec._24727.tech.schema.DIDAuthenticationDataType)1 InputUnitType (iso.std.iso_iec._24727.tech.schema.InputUnitType)1 PasswordAttributesType (iso.std.iso_iec._24727.tech.schema.PasswordAttributesType)1