File indexing completed on 2024-11-24 04:49:38
0001 /* 0002 oidmap.cpp 0003 0004 This file is part of libkleo, the KDE keymanagement library 0005 SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB 0006 SPDX-FileCopyrightText: 2022 Ingo Klöcker <kloecker@kde.org> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #include <config-libkleo.h> 0012 0013 #include "oidmap.h" 0014 0015 #include <QString> 0016 0017 #include <vector> 0018 0019 namespace 0020 { 0021 struct NameAndOID { 0022 const char *name; 0023 const char *oid; 0024 }; 0025 static const std::vector<NameAndOID> oidmap = { 0026 // clang-format off 0027 // keep them ordered by oid: 0028 {"SP", "ST" }, // hack to show the Sphinx-required/desired SP for 0029 // StateOrProvince, otherwise known as ST or even S 0030 {"NameDistinguisher", "0.2.262.1.10.7.20" }, 0031 {"EMAIL", "1.2.840.113549.1.9.1"}, 0032 {"SN", "2.5.4.4" }, 0033 {"SerialNumber", "2.5.4.5" }, 0034 {"T", "2.5.4.12" }, 0035 {"D", "2.5.4.13" }, 0036 {"BC", "2.5.4.15" }, 0037 {"ADDR", "2.5.4.16" }, 0038 {"PC", "2.5.4.17" }, 0039 {"GN", "2.5.4.42" }, 0040 {"Pseudo", "2.5.4.65" }, 0041 // clang-format on 0042 }; 0043 } 0044 0045 const char *Kleo::oidForAttributeName(const QString &attr) 0046 { 0047 QByteArray attrUtf8 = attr.toUtf8(); 0048 for (const auto &m : oidmap) { 0049 if (qstricmp(attrUtf8.constData(), m.name) == 0) { 0050 return m.oid; 0051 } 0052 } 0053 return nullptr; 0054 } 0055 0056 const char *Kleo::attributeNameForOID(const char *oid) 0057 { 0058 for (const auto &m : oidmap) { 0059 if (qstricmp(oid, m.oid) == 0) { 0060 return m.name; 0061 } 0062 } 0063 return nullptr; 0064 }