diff options
author | Thomas <> | 2023-01-12 15:23:34 +0100 |
---|---|---|
committer | Thomas <> | 2023-01-12 15:25:44 +0100 |
commit | 596818361623dbe537536683146c3df2a2fcdbb2 (patch) | |
tree | aad215536448225dae7e88777f70076300e7f771 /pdf-as-common/src/main/java/at/gv | |
parent | c14096c5a87dabcc7483c5ff7bcd7014ee3a0319 (diff) | |
download | pdf-as-4-596818361623dbe537536683146c3df2a2fcdbb2.tar.gz pdf-as-4-596818361623dbe537536683146c3df2a2fcdbb2.tar.bz2 pdf-as-4-596818361623dbe537536683146c3df2a2fcdbb2.zip |
fix(sigblock): add mapping to support old RFC2255 names in signature-profile configurations
Issue: #70
Add a mapping table into DNUtils to map specific RDN names to old format
Diffstat (limited to 'pdf-as-common/src/main/java/at/gv')
-rw-r--r-- | pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/DNUtils.java | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/DNUtils.java b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/DNUtils.java index 2ac91490..810a5d8a 100644 --- a/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/DNUtils.java +++ b/pdf-as-common/src/main/java/at/gv/egiz/pdfas/common/utils/DNUtils.java @@ -3,19 +3,19 @@ * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a * joint initiative of the Federal Chancellery Austria and Graz University of * Technology. - * + * * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by * the European Commission - subsequent versions of the EUPL (the "Licence"); * You may not use this work except in compliance with the Licence. * You may obtain a copy of the Licence at: * http://www.osor.eu/eupl/ - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the Licence is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the Licence for the specific language governing permissions and * limitations under the Licence. - * + * * This product combines work with different licenses. See the "NOTICE" text * file for details on the various modules and licenses. * The "NOTICE" text file is part of the distribution. Any derivative works @@ -23,6 +23,7 @@ ******************************************************************************/ package at.gv.egiz.pdfas.common.utils; +import java.util.Collections; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -31,30 +32,36 @@ import javax.naming.InvalidNameException; import javax.naming.ldap.LdapName; import javax.naming.ldap.Rdn; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - public class DNUtils { - private static final Logger logger = LoggerFactory.getLogger(DNUtils.class); - + private static final Map<String, String> RFC2255_NAME_MAPPER = Collections.unmodifiableMap( + new HashMap<String, String>() { + private static final long serialVersionUID = 3434415954591076154L; + { + put("title", "T"); + } + }); - public static Map<String, String> dnToMap(String dn) throws InvalidNameException { - Map<String, String> map = new HashMap<String, String>(); + public static Map<String, String> dnToMap(String dn) throws InvalidNameException { + final Map<String, String> map = new HashMap<>(); - LdapName ldapName = new LdapName(dn); + final LdapName ldapName = new LdapName(dn); - Iterator<Rdn> rdnIterator = ldapName.getRdns().iterator(); + final Iterator<Rdn> rdnIterator = ldapName.getRdns().iterator(); - while(rdnIterator.hasNext()) { - Rdn rdn = rdnIterator.next(); + while (rdnIterator.hasNext()) { + final Rdn rdn = rdnIterator.next(); + map.put(rdn.getType(), rdn.getValue().toString()); - //logger.debug(rdn.getType() + " = " + rdn.getValue().toString()); - map.put(rdn.getType(), rdn.getValue().toString()); - } + // map specific RFC2255 names to support old PDF-AS signature-profile definitions + if (RFC2255_NAME_MAPPER.containsKey(rdn.getType())) { + map.put(RFC2255_NAME_MAPPER.get(rdn.getType()), rdn.getValue().toString()); - map.put("DN", dn); - //logger.debug("DN = " + dn); - - return map; + } + } + + map.put("DN", dn); + + return map; + } } |