use of org.openecard.gui.definition.ToggleText 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.ToggleText in project open-ecard by ecsec.
the class CVCStep method addElements.
private void addElements() {
Text description = new Text();
description.setText(LANG.translationForKey(DESCRIPTION));
getInputInfoUnits().add(description);
// SubjectName
ToggleText subjectName = new ToggleText();
subjectName.setID("SubjectName");
subjectName.setTitle(LANG.translationForKey(SUBJECT_NAME));
subjectName.setText(eacData.certificateDescription.getSubjectName());
getInputInfoUnits().add(subjectName);
// SubjectURL
ToggleText subjectURL = new ToggleText();
subjectURL.setID("SubjectURL");
subjectURL.setTitle(LANG.translationForKey(SUBJECT_URL));
if (eacData.certificateDescription.getSubjectURL() != null) {
subjectURL.setText(eacData.certificateDescription.getSubjectURL());
} else {
subjectURL.setText("");
}
getInputInfoUnits().add(subjectURL);
// TermsOfUsage
ToggleText termsOfUsage = new ToggleText();
termsOfUsage.setID("TermsOfUsage");
termsOfUsage.setTitle(LANG.translationForKey(TERMS_OF_USAGE));
Document doc = new Document();
doc.setMimeType(eacData.certificateDescription.getTermsOfUsageMimeType());
doc.setValue(eacData.certificateDescription.getTermsOfUsageBytes());
termsOfUsage.setDocument(doc);
termsOfUsage.setCollapsed(true);
getInputInfoUnits().add(termsOfUsage);
// Validity
DateFormat dateFormat;
try {
dateFormat = new SimpleDateFormat(LANG.translationForKey(VALIDITY_FORMAT));
} catch (IllegalArgumentException e) {
dateFormat = new SimpleDateFormat();
}
StringBuilder sb = new StringBuilder(150);
sb.append(LANG.translationForKey(VALIDITY_FROM));
sb.append(" ");
sb.append(dateFormat.format(eacData.certificate.getEffectiveDate().getTime()));
sb.append(" ");
sb.append(LANG.translationForKey(VALIDITY_TO));
sb.append(" ");
sb.append(dateFormat.format(eacData.certificate.getExpirationDate().getTime()));
ToggleText validity = new ToggleText();
validity.setID("Validity");
validity.setTitle(LANG.translationForKey(VALIDITY));
validity.setText(sb.toString());
validity.setCollapsed(true);
getInputInfoUnits().add(validity);
// IssuerName
ToggleText issuerName = new ToggleText();
issuerName.setID("IssuerName");
issuerName.setTitle(LANG.translationForKey(ISSUER_NAME));
issuerName.setText(eacData.certificateDescription.getIssuerName());
issuerName.setCollapsed(true);
getInputInfoUnits().add(issuerName);
// IssuerURL
ToggleText issuerURL = new ToggleText();
issuerURL.setID("IssuerURL");
issuerURL.setTitle(LANG.translationForKey(ISSUER_URL));
// issuer url is optional so perform a null check
if (eacData.certificateDescription.getIssuerURL() != null) {
issuerURL.setText(eacData.certificateDescription.getIssuerURL());
} else {
issuerURL.setText("");
}
issuerURL.setCollapsed(true);
getInputInfoUnits().add(issuerURL);
}
Aggregations