import org.adullact.liberattest.signature.SignatureElement;
import org.adullact.liberattest.utils.HashDocument;
import org.adullact.liberattest.utils.KeyStoreLoader;
+import org.adullact.liberattest.utils.StoreConfig;
import sun.security.util.Debug;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.math.BigInteger;
import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
public class PDFBuilder {
Font.NORMAL, BaseColor.RED);
private static Font greenFont = new Font(Font.FontFamily.HELVETICA, 10,
Font.NORMAL, new BaseColor(0, 100, 0));
+ private static Font warnFont = new Font(Font.FontFamily.HELVETICA, 10,
+ Font.NORMAL, new BaseColor(204, 102, 0));
private static Font titleFont = new Font(Font.FontFamily.HELVETICA, 14,
Font.BOLD);
private static Font subFont = new Font(Font.FontFamily.HELVETICA, 12,
table.addCell("Certificat");
- if (sig.isVerified()) {
+ List<StoreConfig> ksList = KeyStoreLoader.getInstance();
+ Map<String, Boolean> verifications = sig.isVerified();
+ StoreConfig mostValidStore = null;
+ boolean isValid = false;
+ for (StoreConfig ks : ksList) {
+ // We don't handle error validity !
+ if (ks.valid != StoreConfig.Validity.error) {
+ if (ks.valid == StoreConfig.Validity.valid) {
+ if (mostValidStore == null) {
+ mostValidStore = ks;
+ }
+ if (verifications.get(ks.name)) {
+ mostValidStore = ks;
+ isValid = true;
+ break;
+ }
+ } else if (ks.valid == StoreConfig.Validity.warning && verifications.get(ks.name)) {
+ if (mostValidStore == null) {
+ mostValidStore = ks;
+ }
+ if (verifications.get(ks.name)) {
+ mostValidStore = ks;
+ isValid = true;
+ }
+ }
+ }
+ }
+ if (!isValid) {
table.addCell(new Phrase(
- "Le certificat a été vérifié avec succès à l'aide du référenciel " + KeyStoreLoader.getStore() + ".",
- greenFont));
+ "Le certificat n'a pas pu être vérifié.",
+ redFont));
} else {
table.addCell(new Phrase(
- "Le certificat n'a pas pu être vérifié à l'aide du référenciel " + KeyStoreLoader.getStore() + ".",
- redFont));
+ "Le certificat a été vérifié avec succès à l'aide du référenciel " + mostValidStore.name + ".",
+ mostValidStore.valid == StoreConfig.Validity.valid ? greenFont : warnFont));
}
table.addCell("Révocation");