diff options
author | tkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2011-07-13 13:17:25 +0000 |
---|---|---|
committer | tkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2011-07-13 13:17:25 +0000 |
commit | c9a78b2fe698cfcb22f0928305043aafa8bff7f9 (patch) | |
tree | 34238eb9a822bf6e0fe4a7a29aaf717c38f5af37 /smcc/src/main/java/at/gv/egiz | |
parent | 8d5062f78ed98509bd27ffb9e75cfa8a0bc12767 (diff) | |
download | mocca-c9a78b2fe698cfcb22f0928305043aafa8bff7f9.tar.gz mocca-c9a78b2fe698cfcb22f0928305043aafa8bff7f9.tar.bz2 mocca-c9a78b2fe698cfcb22f0928305043aafa8bff7f9.zip |
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
Diffstat (limited to 'smcc/src/main/java/at/gv/egiz')
-rw-r--r-- | smcc/src/main/java/at/gv/egiz/smcc/ACOSCard.java | 28 |
1 files changed, 23 insertions, 5 deletions
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);
|