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