From c9a78b2fe698cfcb22f0928305043aafa8bff7f9 Mon Sep 17 00:00:00 2001 From: tkellner Date: Wed, 13 Jul 2011 13:17:25 +0000 Subject: ACOSCard: More lenient certificate parsing to find country git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@945 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4 --- smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java | 28 +++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'smcc') diff --git a/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java b/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java index e42370dc..b5515111 100644 --- a/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java +++ b/smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java @@ -173,11 +173,29 @@ PINMgmtSignatureCard { try { byte[] cert = getCertificate(KeyboxName.SECURE_SIGNATURE_KEYPAIR, null); - ASN1 asn1 = new ASN1(cert); - - String countryID = asn1.getElementAt(0).getElementAt(3).getElementAt(0).getElementAt(0).getElementAt(1).gvString(); + ASN1 cert_asn1 = new ASN1(cert); + // certificate + // +-tbsCertificate(0) + // +-... + // +-issuer(3) + // +-[RelativeDistinguishedName] + // +-[AttributeValueAssertion] + // +-attributeType + // +-attributeValue + ASN1 issuer = cert_asn1.getElementAt(0).getElementAt(3); + String countryID = null; + for (int i = 0; i < issuer.getSize(); ++i) { + if (issuer.getElementAt(i).getElementAt(0).getElementAt(0).gvString() == ASN1.OID_NAME_C) { + countryID = issuer.getElementAt(i).getElementAt(0).getElementAt(1).gvString(); + break; + } + } - if(countryID.equalsIgnoreCase("LI")) { + if (countryID == null) { + log.debug("No Country found! - default to ACOS Austria."); + _infoboxHandler = new ACOSATCard(this); + } + else if (countryID.equalsIgnoreCase("LI")) { log.debug("Identified lisign card."); _infoboxHandler = new ACOSLIESignCard(this); } else { @@ -185,7 +203,7 @@ PINMgmtSignatureCard { _infoboxHandler = new ACOSATCard(this); } } catch (SignatureCardException e) { - log.warn("Cannot determine card type by certificate. Using default.", e); + log.warn("Cannot determine card type by certificate. Using default.", e); _infoboxHandler = new ACOSATCard(this); } catch (IOException e) { log.warn("Cannot determine card type by certificate. Using default.", e); -- cgit v1.2.3