Libkleo

oidmap.cpp
1/*
2 oidmap.cpp
3
4 This file is part of libkleo, the KDE keymanagement library
5 SPDX-FileCopyrightText: 2008 Klarälvdalens Datakonsult AB
6 SPDX-FileCopyrightText: 2022 Ingo Klöcker <kloecker@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10
11#include <config-libkleo.h>
12
13#include "oidmap.h"
14
15#include <QString>
16
17#include <vector>
18
19namespace
20{
21struct NameAndOID {
22 const char *name;
23 const char *oid;
24};
25static const std::vector<NameAndOID> oidmap = {
26 // clang-format off
27 // keep them ordered by oid:
28 {"SP", "ST" }, // hack to show the Sphinx-required/desired SP for
29 // StateOrProvince, otherwise known as ST or even S
30 {"NameDistinguisher", "0.2.262.1.10.7.20" },
31 {"EMAIL", "1.2.840.113549.1.9.1"},
32 {"SN", "2.5.4.4" },
33 {"SerialNumber", "2.5.4.5" },
34 {"T", "2.5.4.12" },
35 {"D", "2.5.4.13" },
36 {"BC", "2.5.4.15" },
37 {"ADDR", "2.5.4.16" },
38 {"PC", "2.5.4.17" },
39 {"GN", "2.5.4.42" },
40 {"Pseudo", "2.5.4.65" },
41 // clang-format on
42};
43}
44
45const char *Kleo::oidForAttributeName(const QString &attr)
46{
47 QByteArray attrUtf8 = attr.toUtf8();
48 for (const auto &m : oidmap) {
49 if (qstricmp(attrUtf8.constData(), m.name) == 0) {
50 return m.oid;
51 }
52 }
53 return nullptr;
54}
55
56const char *Kleo::attributeNameForOID(const char *oid)
57{
58 for (const auto &m : oidmap) {
59 if (qstricmp(oid, m.oid) == 0) {
60 return m.name;
61 }
62 }
63 return nullptr;
64}
const char * constData() const const
QByteArray toUtf8() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:09:14 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.