summaryrefslogtreecommitdiff
path: root/include/modules/ns_cert.h
blob: 07830388405a16ec4b34052db1166a8eb000208a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* NickServ core functions
 *
 * (C) 2003-2024 Anope Team
 * Contact us at team@anope.org
 *
 * Please read COPYING and README for further details.
 *
 * Based on the original code of Epona by Lara.
 * Based on the original code of Services by Andy Church.
 */

#pragma once

struct NSCertList
{
protected:
	NSCertList() = default;
public:
	virtual ~NSCertList() = default;

	/** Add an entry to the nick's certificate list
	 *
	 * @param entry The fingerprint to add to the cert list
	 *
	 * Adds a new entry into the cert list.
	 */
	virtual void AddCert(const Anope::string &entry) = 0;

	/** Get an entry from the nick's cert list by index
	 *
	 * @param entry Index in the certificate list vector to retrieve
	 * @return The fingerprint entry of the given index if within bounds, an empty string if the vector is empty or the index is out of bounds
	 *
	 * Retrieves an entry from the certificate list corresponding to the given index.
	 */
	virtual Anope::string GetCert(unsigned entry) const = 0;

	virtual unsigned GetCertCount() const = 0;

	/** Find an entry in the nick's cert list
	 *
	 * @param entry The fingerprint to search for
	 * @return True if the fingerprint is found in the cert list, false otherwise
	 *
	 * Search for an fingerprint within the cert list.
	 */
	virtual bool FindCert(const Anope::string &entry) const = 0;

	/** Erase a fingerprint from the nick's certificate list
	 *
	 * @param entry The fingerprint to remove
	 *
	 * Removes the specified fingerprint from the cert list.
	 */
	virtual void EraseCert(const Anope::string &entry) = 0;

	/** Replaces a fingerprint in the nick's certificate list
	 *
	 * @param oldentry The old fingerprint to remove
	 * @param newentry The new fingerprint to add
	 *
	 * Replaces the specified fingerprint in the cert list.
	 */
	virtual void ReplaceCert(const Anope::string &oldentry, const Anope::string &newentry) = 0;

	/** Clears the entire nick's cert list
	 *
	 * Deletes all the memory allocated in the certificate list vector and then clears the vector.
	 */
	virtual void ClearCert() = 0;

	virtual void Check() = 0;
};

class CertService
	: public Service
{
public:
	CertService(Module *c) : Service(c, "CertService", "certs") { }

	virtual NickCore *FindAccountFromCert(const Anope::string &cert) = 0;
	virtual void ReplaceCert(const Anope::string &oldcert, const Anope::string &newcert) = 0;
};