21#include <rtl/ustring.hxx>
22#include <com/sun/star/security/ExtAltNameType.hpp>
23#include <com/sun/star/security/CertAltNameEntry.hpp>
24#include <com/sun/star/beans/PropertyValue.hpp>
38 int GetNamesLength(CERTGeneralName *names)
41 CERTGeneralName *
first;
44 if (names !=
nullptr) {
47 names = CERT_GetNextGeneralName(names);
48 }
while (names != first);
62 item.type = siDERCertBuffer;
67 CERTGeneralName *nameList;
68 arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
71 return css::uno::Sequence<css::security::CertAltNameEntry>();
73 nameList = CERT_DecodeAltNameExtension(arena, &item);
75 CERTGeneralName* current = nameList;
77 int size = GetNamesLength(nameList);
79 for(
int i = 0;
i <
size; ++
i){
80 switch (current->type) {
83 css::beans::PropertyValue otherNameProp;
84 otherNameProp.Name = OUString::createFromAscii(CERT_GetOidString(¤t->name.OthName.oid));
87 auto otherNameRange = asNonConstRange(otherName);
88 for(
unsigned int r = 0; r < current->name.OthName.name.len ; r ++ )
89 otherNameRange[r] = *( current->name.OthName.name.data + r ) ;
91 otherNameProp.Value <<= otherName;
97 m_Entries[
i].Type = ExtAltNameType_RFC822_NAME;
98 m_Entries[
i].Value <<= OUString(
reinterpret_cast<char*
>(current->name.other.data), current->name.other.len, RTL_TEXTENCODING_ASCII_US);
102 m_Entries[
i].Value <<= OUString(
reinterpret_cast<char*
>(current->name.other.data), current->name.other.len, RTL_TEXTENCODING_ASCII_US);
104 case certX400Address: {
106 m_Entries[
i].Type = ExtAltNameType_X400_ADDRESS;
109 case certDirectoryName: {
111 m_Entries[
i].Type = ExtAltNameType_DIRECTORY_NAME;
114 case certEDIPartyName: {
116 m_Entries[
i].Type = ExtAltNameType_EDI_PARTY_NAME;
121 m_Entries[
i].Value <<= OUString(
reinterpret_cast<char*
>(current->name.other.data), current->name.other.len, RTL_TEXTENCODING_ASCII_US);
123 case certIPAddress: {
124 m_Entries[
i].Type = ExtAltNameType_IP_ADDRESS;
127 auto ipAddressRange = asNonConstRange(ipAddress);
128 for(
unsigned int r = 0; r < current->name.other.len ; r ++ )
129 ipAddressRange[r] = *( current->name.other.data + r ) ;
135 m_Entries[
i].Type = ExtAltNameType_REGISTERED_ID;
138 OString nssOid(CERT_GetOidString(¤t->name.other));
140 m_Entries[
i].Value <<= OStringToOUString( unoOid, RTL_TEXTENCODING_ASCII_US );
143 current = CERT_GetNextGeneralName(current);
146 PORT_FreeArena(arena, PR_FALSE);
149 return comphelper::containerToSequence<css::security::CertAltNameEntry>(
m_Entries);
155 constexpr std::string_view oid(
"OID.");
156 if (oidString.match(oid))
157 objID = oidString.copy(oid.size());
static OString removeOIDFromString(const OString &oid)
CertificateExtension_CertExtn m_Extn
virtual css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL getAlternativeNames() override
css::uno::Sequence< css::security::CertAltNameEntry > m_Entries
constexpr OUStringLiteral first
css::uno::Sequence< sal_Int8 > m_xExtnValue