Search in sources :

Example 6 with Checkbox

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

the class CHATStep method addElements.

private void addElements() {
    Text decription = new Text();
    String decriptionText = LANG.translationForKey(DESCRIPTION, eacData.certificateDescription.getSubjectName());
    decription.setText(decriptionText);
    getInputInfoUnits().add(decription);
    // process read access and special functions
    Checkbox readAccessCheckBox = new Checkbox(READ_CHAT_BOXES);
    boolean displayReadAccessCheckBox = false;
    readAccessCheckBox.setGroupText(LANG.translationForKey(READ_ACCESS_DESC));
    Map<CHAT.DataGroup, Boolean> requiredReadAccess = eacData.requiredCHAT.getReadAccess();
    Map<CHAT.DataGroup, Boolean> optionalReadAccess = eacData.optionalCHAT.getReadAccess();
    Map<CHAT.SpecialFunction, Boolean> requiredSpecialFunctions = eacData.requiredCHAT.getSpecialFunctions();
    Map<CHAT.SpecialFunction, Boolean> optionalSpecialFunctions = eacData.optionalCHAT.getSpecialFunctions();
    // iterate over all 22 eID application data groups
    for (CHAT.DataGroup dataGroup : requiredReadAccess.keySet()) {
        if (TR03119RightsFilter.isTr03119ConformReadRight(dataGroup)) {
            if (requiredReadAccess.get(dataGroup)) {
                displayReadAccessCheckBox = true;
                readAccessCheckBox.getBoxItems().add(makeBoxItem(dataGroup, true, true));
            } else if (optionalReadAccess.get(dataGroup)) {
                displayReadAccessCheckBox = true;
                readAccessCheckBox.getBoxItems().add(makeBoxItem(dataGroup, true, false));
            }
        } else {
            eacData.requiredCHAT.setReadAccess(dataGroup, false);
        }
    }
    // iterate over all 8 special functions
    for (CHAT.SpecialFunction specialFunction : requiredSpecialFunctions.keySet()) {
        // determine if extra data is necessary
        Object[] textData = new Object[0];
        if (CHAT.SpecialFunction.AGE_VERIFICATION == specialFunction) {
            Calendar c = eacData.aad.getAgeVerificationData();
            if (c != null) {
                int yearDiff = getYearDifference(c);
                textData = new Object[] { yearDiff };
            } else {
                // disable this function as no working reference value is given
                eacData.requiredCHAT.setSpecialFunctions(specialFunction, false);
                continue;
            }
        }
        if (TR03119RightsFilter.isTr03119ConformSpecialFunction(specialFunction)) {
            if (requiredSpecialFunctions.get(specialFunction)) {
                displayReadAccessCheckBox = true;
                readAccessCheckBox.getBoxItems().add(makeBoxItem(specialFunction, true, true, textData));
            } else if (optionalSpecialFunctions.get(specialFunction)) {
                displayReadAccessCheckBox = true;
                readAccessCheckBox.getBoxItems().add(makeBoxItem(specialFunction, true, false, textData));
            }
        } else {
            eacData.requiredCHAT.setSpecialFunctions(specialFunction, false);
        }
    }
    if (displayReadAccessCheckBox) {
        getInputInfoUnits().add(readAccessCheckBox);
    }
    // process write access
    Checkbox writeAccessCheckBox = new Checkbox(WRITE_CHAT_BOXES);
    boolean displayWriteAccessCheckBox = false;
    writeAccessCheckBox.setGroupText(LANG.translationForKey(WRITE_ACCESS_DESC));
    Map<CHAT.DataGroup, Boolean> requiredWriteAccess = eacData.requiredCHAT.getWriteAccess();
    Map<CHAT.DataGroup, Boolean> optionalWriteAccess = eacData.optionalCHAT.getWriteAccess();
    // iterate over DG17-DG21 of the eID application data groups
    for (CHAT.DataGroup dataGroup : requiredWriteAccess.keySet()) {
        if (TR03119RightsFilter.isTr03119ConformWriteRight(dataGroup)) {
            if (requiredWriteAccess.get(dataGroup)) {
                displayWriteAccessCheckBox = true;
                writeAccessCheckBox.getBoxItems().add(makeBoxItem(dataGroup, true, true));
            } else if (optionalWriteAccess.get(dataGroup)) {
                displayWriteAccessCheckBox = true;
                writeAccessCheckBox.getBoxItems().add(makeBoxItem(dataGroup, true, false));
            }
        } else {
            eacData.requiredCHAT.setWriteAccess(dataGroup, false);
        }
    }
    if (displayWriteAccessCheckBox) {
        getInputInfoUnits().add(writeAccessCheckBox);
    }
    ToggleText requestedDataDescription = new ToggleText();
    requestedDataDescription.setTitle(LANG.translationForKey(NOTE));
    requestedDataDescription.setText(LANG.translationForKey(NOTE_CONTENT));
    requestedDataDescription.setCollapsed(!true);
    getInputInfoUnits().add(requestedDataDescription);
}
Also used : ToggleText(org.openecard.gui.definition.ToggleText) CHAT(org.openecard.crypto.common.asn1.cvc.CHAT) Calendar(java.util.Calendar) ToggleText(org.openecard.gui.definition.ToggleText) Text(org.openecard.gui.definition.Text) Checkbox(org.openecard.gui.definition.Checkbox)

Example 7 with Checkbox

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

the class CHATStepAction method processResult.

private void processResult(Map<String, ExecutionResults> results) {
    List<String> dataGroupsNames = getDataGroupNames();
    List<String> specialFunctionsNames = getSpecialFunctionNames();
    ExecutionResults executionResults = results.get(getStepID());
    // process read access and special functions
    Checkbox cbRead = (Checkbox) executionResults.getResult(CHATStep.READ_CHAT_BOXES);
    if (cbRead != null) {
        CHAT selectedCHAT = eacData.requiredCHAT;
        for (BoxItem item : cbRead.getBoxItems()) {
            if (dataGroupsNames.contains(item.getName())) {
                selectedCHAT.setReadAccess(item.getName(), item.isChecked());
            } else if (specialFunctionsNames.contains(item.getName())) {
                selectedCHAT.setSpecialFunction(item.getName(), item.isChecked());
            }
        }
    }
    // process write access
    Checkbox cbWrite = (Checkbox) executionResults.getResult(CHATStep.WRITE_CHAT_BOXES);
    if (cbWrite != null) {
        CHAT selectedCHAT = eacData.requiredCHAT;
        for (BoxItem item : cbWrite.getBoxItems()) {
            if (dataGroupsNames.contains(item.getName())) {
                selectedCHAT.setWriteAccess(item.getName(), item.isChecked());
            }
        }
    }
}
Also used : ExecutionResults(org.openecard.gui.executor.ExecutionResults) Checkbox(org.openecard.gui.definition.Checkbox) CHAT(org.openecard.crypto.common.asn1.cvc.CHAT) BoxItem(org.openecard.gui.definition.BoxItem)

Aggregations

Checkbox (org.openecard.gui.definition.Checkbox)7 ToggleText (org.openecard.gui.definition.ToggleText)5 BoxItem (org.openecard.gui.definition.BoxItem)3 Step (org.openecard.gui.definition.Step)3 Text (org.openecard.gui.definition.Text)3 CHAT (org.openecard.crypto.common.asn1.cvc.CHAT)2 BoxItem (org.openecard.gui.android.eac.types.BoxItem)2 ExecutionResults (org.openecard.gui.executor.ExecutionResults)2 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 StepResult (org.openecard.gui.StepResult)1 ServerData (org.openecard.gui.android.eac.types.ServerData)1 TermsOfUsage (org.openecard.gui.android.eac.types.TermsOfUsage)1 Document (org.openecard.gui.definition.Document)1 InputInfoUnit (org.openecard.gui.definition.InputInfoUnit)1 PasswordField (org.openecard.gui.definition.PasswordField)1 StepAction (org.openecard.gui.executor.StepAction)1 StepActionResult (org.openecard.gui.executor.StepActionResult)1 PINStep (org.openecard.sal.protocol.eac.gui.PINStep)1