summaryrefslogtreecommitdiffstats
path: root/rdcp_realmdrealm.h
blob: cc703956ba47eb17b1acbac231ba88700da1ef14 (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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
#ifndef __RDCP_REALMDREALM_H__
#define __RDCP_REALMDREALM_H__

#include <strings.h>
#include "LMI_RealmdRealm.h"
#include "LMI_RealmdKerberosRealm.h"


KINLINE LMI_RealmdKerberosRealm_SupportedJoinCredentialTypes_Enum
SupportedJoinCredentialTypes_name_to_enum(const char *name)
{
    if (strcasecmp(name, "ccache"))
        return LMI_RealmdKerberosRealm_SupportedJoinCredentialTypes_ccache;
    if (strcasecmp(name, "password"))
        return LMI_RealmdKerberosRealm_SupportedJoinCredentialTypes_password;
    if (strcasecmp(name, "secrect"))
        return LMI_RealmdKerberosRealm_SupportedJoinCredentialTypes_secrect;
    if (strcasecmp(name, "automatic"))
        return LMI_RealmdKerberosRealm_SupportedJoinCredentialTypes_automatic;
    return 0;
}

KINLINE const char *
SupportedJoinCredentialTypes_enum_to_name(LMI_RealmdKerberosRealm_SupportedJoinCredentialTypes_Enum value)
{
    switch(value) {
    case LMI_RealmdKerberosRealm_SupportedJoinCredentialTypes_ccache:
        return "ccache";
    case LMI_RealmdKerberosRealm_SupportedJoinCredentialTypes_password:
        return "password";
    case LMI_RealmdKerberosRealm_SupportedJoinCredentialTypes_secrect:
        return "secrect";
    case LMI_RealmdKerberosRealm_SupportedJoinCredentialTypes_automatic:
        return "automatic";
    default:
        return NULL;
    }
}

KINLINE LMI_RealmdKerberosRealm_SupportedJoinCredentialOwners_Enum
SupportedJoinCredentialOwners_name_to_enum(const char *name)
{
    if (strcasecmp(name, "administrator"))
        return LMI_RealmdKerberosRealm_SupportedJoinCredentialOwners_administrator;
    if (strcasecmp(name, "user"))
        return LMI_RealmdKerberosRealm_SupportedJoinCredentialOwners_user;
    if (strcasecmp(name, "computer"))
        return LMI_RealmdKerberosRealm_SupportedJoinCredentialOwners_computer;
    if (strcasecmp(name, "none"))
        return LMI_RealmdKerberosRealm_SupportedJoinCredentialOwners_none;
    return 0;
}

KINLINE const char *
SupportedJoinCredentialOwners_enum_to_name(LMI_RealmdKerberosRealm_SupportedJoinCredentialOwners_Enum value)
{
    switch(value) {
    case LMI_RealmdKerberosRealm_SupportedJoinCredentialOwners_administrator:
        return "administrator";
    case LMI_RealmdKerberosRealm_SupportedJoinCredentialOwners_user:
        return "user";
    case LMI_RealmdKerberosRealm_SupportedJoinCredentialOwners_computer:
        return "computer";
    case LMI_RealmdKerberosRealm_SupportedJoinCredentialOwners_none:
        return "none";
    default:
        return NULL;
    }
}

KINLINE LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_Enum
SupportedLeaveCredentialTypes_name_to_enum(const char *name)
{
    if (strcasecmp(name, "ccache"))
        return LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_ccache;
    if (strcasecmp(name, "password"))
        return LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_password;
    if (strcasecmp(name, "secrect"))
        return LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_secrect;
    if (strcasecmp(name, "automatic"))
        return LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_automatic;
    return 0;
}

KINLINE const char *SupportedLeaveCredentialTypes_enum_to_name(LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_Enum value)
{
    switch(value) {
    case LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_ccache:
        return "ccache";
    case LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_password:
        return "password";
    case LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_secrect:
        return "secrect";
    case LMI_RealmdKerberosRealm_SupportedLeaveCredentialTypes_automatic:
        return "automatic";
    default:
        return NULL;
    }
}

KINLINE LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_Enum
SupportedLeaveCredentialOwners_name_to_enum(const char *name)
{
    if (strcasecmp(name, "administrator"))
        return LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_administrator;
    if (strcasecmp(name, "user"))
        return LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_user;
    if (strcasecmp(name, "computer"))
        return LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_computer;
    if (strcasecmp(name, "none"))
        return LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_none;
    return 0;
}

KINLINE const char *
SupportedLeaveCredentialOwners_enum_to_name(LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_Enum value)
{
    switch(value) {
    case LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_administrator:
        return "administrator";
    case LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_user:
        return "user";
    case LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_computer:
        return "computer";
    case LMI_RealmdKerberosRealm_SupportedLeaveCredentialOwners_none:
        return "none";
    default:
        return NULL;
    }
}

#define LMI_RealmdRealmInitKeys(klass, obj, dbus_path)                  \
{                                                                       \
    gchar *instance_id = NULL;                                          \
    const char *host_name = get_system_name();                          \
                                                                        \
    klass##_Init(obj, cb, ns);                                          \
                                                                        \
    instance_id = instance_id_from_dbus_path(dbus_path);                \
    klass##_Set_InstanceID(obj, instance_id);                           \
    g_free(instance_id);                                                \
                                                                        \
    klass##_Set_SystemCreationClassName(obj, get_system_creation_class_name()); \
    klass##_Set_SystemName(obj, host_name);                             \
}

KINLINE bool SupportsDBusInterface(GVariant *dbus_props, const char *dbus_interface)
{
    bool result = false;
    GVariantIter *iter = NULL;
    gchar *value;

    if (g_variant_lookup(dbus_props, "SupportedInterfaces", "as", &iter)) {
        while (g_variant_iter_next(iter, "&s", &value)) {
            if (strcmp(value, dbus_interface) == 0) {
                result = true;
                break;
            }
        }
        g_variant_iter_free(iter);
    }
    return result;
}

#define LMI_InitFromDBusRealmProps(klass, obj, dbus_props)              \
{                                                                       \
    gchar *value = NULL;                                                \
    gchar *name = NULL;                                                 \
    gsize n_items;                                                      \
    GVariantIter *iter;                                                 \
    CMPICount i;                                                        \
                                                                        \
    if (g_variant_lookup(dbus_props, "Name", "&s", &value)) {           \
        klass##_Set_RealmName(obj, value);                              \
    }                                                                   \
                                                                        \
    if (g_variant_lookup(dbus_props, "Configured", "&s", &value)) {     \
        klass##_Set_Configured(obj, value);                             \
    }                                                                   \
                                                                        \
    if (g_variant_lookup(dbus_props, "SupportedInterfaces", "as", &iter)) { \
        n_items = g_variant_iter_n_children(iter);                      \
        klass##_Init_SupportedInterfaces(obj, n_items);                 \
        for (i = 0; g_variant_iter_next(iter, "&s", &value); i++) {     \
            klass##_Set_SupportedInterfaces(obj, i, value);             \
        }                                                               \
        g_variant_iter_free(iter);                                      \
    }                                                                   \
                                                                        \
    if (g_variant_lookup(dbus_props, "Details", "a(ss)", &iter)) {         \
        n_items = g_variant_iter_n_children(iter);                      \
        klass##_Init_DetailNames(obj, n_items);                         \
        klass##_Init_DetailValues(obj, n_items);                        \
        for (i = 0; g_variant_iter_next(iter, "(&s&s)", &name, &value); i++) { \
            klass##_Set_DetailNames(obj, i, name);                      \
            klass##_Set_DetailValues(obj, i, value);                    \
        }                                                               \
        g_variant_iter_free(iter);                                      \
    }                                                                   \
                                                                        \
    if (g_variant_lookup(dbus_props, "LoginFormats", "as", &iter)) {    \
        n_items = g_variant_iter_n_children(iter);                      \
        klass##_Init_LoginFormats(obj, n_items);                        \
        for (i = 0; g_variant_iter_next(iter, "&s", &value); i++) {     \
            klass##_Set_LoginFormats(obj, i, value);                    \
        }                                                               \
        g_variant_iter_free(iter);                                      \
    }                                                                   \
                                                                        \
    if (g_variant_lookup(dbus_props, "LoginPolicy", "&s", &value)) {    \
        klass##_Set_LoginPolicy(obj, value);                            \
    }                                                                   \
                                                                        \
    if (g_variant_lookup(dbus_props, "PermittedLogins", "as", &iter)) { \
        n_items = g_variant_iter_n_children(iter);                      \
        klass##_Init_PermittedLogins(obj, n_items);                     \
        for (i = 0; g_variant_iter_next(iter, "&s", &value); i++) {     \
            klass##_Set_PermittedLogins(obj, i, value);                 \
        }                                                               \
        g_variant_iter_free(iter);                                      \
    }                                                                   \
}

#define LMI_InitFromDBusKerberosRealmProps(klass, obj, dbus_props)      \
{                                                                       \
    gchar *value = NULL;                                                \
                                                                        \
    if (g_variant_lookup(dbus_props, "RealmName", "&s", &value)) {      \
        klass##_Set_RealmName(obj, value);                              \
    }                                                                   \
                                                                        \
    if (g_variant_lookup(dbus_props, "DomainName", "&s", &value)) {     \
        klass##_Set_DomainName(obj, value);                             \
    }                                                                   \
}

#define LMI_InitFromDBusKerberosMembershipProps(klass, obj, dbus_props) \
{                                                                       \
    gchar *value = NULL;                                                \
    gchar *type = NULL;                                                 \
    gchar *owner = NULL;                                                \
    gsize n_items;                                                      \
    GVariantIter *iter;                                                 \
    CMPICount i;                                                        \
                                                                        \
    if (g_variant_lookup(dbus_props, "SuggestedAdministrator", "&s", &value)) { \
        klass##_Set_SuggestedAdministrator(obj, value);                 \
    }                                                                   \
                                                                        \
    if (g_variant_lookup(dbus_props, "SupportedJoinCredentials", "a(ss)", &iter)) { \
        n_items = g_variant_iter_n_children(iter);                      \
        klass##_Init_SupportedJoinCredentialTypes(obj, n_items);        \
        klass##_Init_SupportedJoinCredentialOwners(obj, n_items);       \
        for (i = 0; g_variant_iter_next(iter, "(&s&s)", &type, &owner); i++) { \
            klass##_Set_SupportedJoinCredentialTypes(obj, i,            \
                                                     SupportedJoinCredentialTypes_name_to_enum(type)); \
            klass##_Set_SupportedJoinCredentialOwners(obj, i,           \
                                                     SupportedJoinCredentialOwners_name_to_enum(owner)); \
        }                                                               \
        g_variant_iter_free(iter);                                      \
    }                                                                   \
                                                                        \
    if (g_variant_lookup(dbus_props, "SupportedLeaveCredentials", "a(ss)", &iter)) { \
        n_items = g_variant_iter_n_children(iter);                      \
        klass##_Init_SupportedLeaveCredentialTypes(obj, n_items);       \
        klass##_Init_SupportedLeaveCredentialOwners(obj, n_items);      \
        for (i = 0; g_variant_iter_next(iter, "(&s&s)", &type, &owner); i++) { \
            klass##_Set_SupportedLeaveCredentialTypes(obj, i,           \
                                                     SupportedLeaveCredentialTypes_name_to_enum(type)); \
            klass##_Set_SupportedLeaveCredentialOwners(obj, i,          \
                                                     SupportedLeaveCredentialOwners_name_to_enum(owner)); \
        }                                                               \
        g_variant_iter_free(iter);                                      \
    }                                                                   \
}

CMPIStatus LMI_RealmdRealmRef_InitFromDBusPath(
    LMI_RealmdRealmRef* self,
    const CMPIBroker* cb,
    const char* ns,
    const char* dbus_path);


CMPIStatus LMI_RealmdRealm_InitFromDBusPath(
    LMI_RealmdRealm* self,
    const CMPIBroker* cb,
    const char* ns,
    const char* dbus_path);

CMPIStatus LMI_RealmdKerberosRealmRef_InitFromDBusPath(
    LMI_RealmdKerberosRealmRef* self,
    const CMPIBroker* cb,
    const char* ns,
    const char* dbus_path);

CMPIStatus LMI_RealmdKerberosRealm_InitFromDBusPath(
    LMI_RealmdKerberosRealm* self,
    const CMPIBroker* cb,
    const char* ns,
    const char* dbus_path);

#endif /* __RDCP_REALMDREALM_H__ */