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);
}
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());
}
}
}
}
Aggregations