summaryrefslogtreecommitdiffstats
path: root/ipalib/plugins/internal.py
blob: ef1326265cc837d536e58a35a300cfd9009e2e79 (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
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
# Authors:
#   Pavel Zuna <pzuna@redhat.com>
#   Adam Young <ayoung@redhat.com>
#   Endi S. Dewata <edewata@redhat.com>
#
# Copyright (c) 2010  Red Hat
# See file 'copying' for use and warranty information
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

"""
Plugins not accessible directly through the CLI, commands used internally
"""

import json

from ipalib import api, errors
from ipalib import Command
from ipalib import Str
from ipalib.output import Output
from ipalib.text import _
from ipalib.util import json_serialize

class json_metadata(Command):
    """
    Export plugin meta-data for the webUI.
    """
    NO_CLI = True


    takes_args = (
        Str('objname?',
            doc=_('Name of object to export'),
        ),
        Str('methodname?',
            doc=_('Name of method to export'),
        ),
    )

    has_output = (
        Output('objects', dict, doc=_('Dict of JSON encoded IPA Objects')),
        Output('methods', dict, doc=_('Dict of JSON encoded IPA Methods')),
    )

    def execute(self, objname, methodname):

        if objname and objname in self.api.Object:

            objects = dict(
                (objname, json_serialize(self.api.Object[objname]))
            )

        else:
            objects = dict(
                (o.name, json_serialize(o)) for o in self.api.Object()
            )

        if methodname and methodname in self.api.Method:

            methods = dict(
                (methodname, json_serialize(self.api.Method[methodname]))
            )

        else:
            methods = dict(
                (m.name, json_serialize(m)) for m in self.api.Method()
            )

        retval = dict([
            ("objects", objects),
            ("methods", methods),
        ])

        return retval

    def output_for_cli(self, textui, result, *args, **options):
        print json.dumps(result, default=json_serialize)

api.register(json_metadata)

class i18n_messages(Command):
    NO_CLI = True

    messages={
        "login": {"header" :_("Logged In As")},
        "objects": {
            "aci": {
                "attribute":_("Attribute"),
                },
            "automountlocation": {
                "add":_("Add Automount Location"),
                "identity":_("Automount Location Settings"),
                },
            "cert": {
                "unspecified":_("Unspecified"),
                "key_compromise":_("Key Compromise"),
                "ca_compromise":_("CA Compromise"),
                "affiliation_changed":_("Affiliation Changed"),
                "superseded":_("Superseded"),
                "cessation_of_operation":_("Cessation of Operation"),
                "certificate_hold":_("Certificate Hold"),
                "remove_from_crl":_("Remove from CRL"),
                "privilege_withdrawn":_("Privilege Withdrawn"),
                "aa_compromise":_("AA Compromise"),
                "revoke_confirmation":_(
                    "To confirm your intention to revoke this certificate, "+
                    "select a reason from the pull-down list, and click "+
                    "the \"Revoke\" button."),
                "note":_("Note"),
                "reason":_("Reason for Revocation"),
                "restore_confirmation":_(
                    "To confirm your intention to restore this certificate, "+
                    "click the \"Restore\" button."),
                "issued_to":_("Issued To"),
                "common_name":_("Common Name"),
                "organization":_("Organization"),
                "organizational_unit":_("Organizational Unit"),
                "serial_number":_("Serial Number"),
                "issued_by":_("Issued By"),
                "validity":_("Validity"),
                "issued_on":_("Issued On"),
                "expires_on":_("Expires On"),
                "fingerprints":_("Fingerprints"),
                "sha1_fingerprint":_("SHA1 Fingerprint"),
                "md5_fingerprint":_("MD5 Fingerprint"),
                "enter_csr":_("Enter the Base64-encoded CSR below"),
                "valid":_("Valid Certificate Present"),
                "new_certificate":_("New Certificate"),
                "revoked":_("Certificate Revoked"),
                "missing":_("No Valid Certificate"),
                "view_certificate":_("Certificate for ${entity} ${primary_key}"),
                "issue_certificate":_("Issue New Certificate for ${entity} ${primary_key}"),
                "revoke_certificate":_("Revoke Certificate for ${entity} ${primary_key}"),
                "restore_certificate":_("Restore Certificate for ${entity} ${primary_key}"),
                },
            "config": {
                "ipaserver":_("Configuration"),
                "cn":_("Name"),
                },
            "delegation": {
                "add":_("Add Delegation"),
                },
            "dnszone": {
                "add":_("Add DNS Zone"),
                "identity":_("DNS Zone Settings"),
                },
            "dnsrecord": {
                "add":_("Add DNS Resource Record"),
                "resource":_("Resource"),
                "type":_("Type"),
                "data":_("Data"),
                "title":_("Records for DNS Zone"),
                },
            "group": {
                "add":_("Add New Group"),
                "details":_("Group Settings"),
                "posix":_("Is this a POSIX group?"),
                },
            "hbacrule": {
                "add":_("Add New Rule"),
                "active":_("Active"),
                "allow":_("Allow"),
                "deny":_("Deny"),
                "inactive":_("Inactive"),
                "ipaenabledflag":_("Rule status"),
                "user":_("Who"),
                "anyone":_("Anyone"),
                "specified_users":_("Specified Users and Groups"),
                "host":_("Accessing"),
                "any_host":_("Any Host"),
                "specified_hosts":_("Specified Hosts and Groups"),
                "service":_("Via Service"),
                "any_service":_("Any Service"),
                "specified_services":_("Specified Services and Groups"),
                "sourcehost":_("From"),
                },
            "hbacsvc": {
                "add":_("Add New HBAC Service"),
                },
            "hbacsvcgroup": {
                "add":_("Add New HBAC Service Group"),
                "services":_("Services"),
                },
            "host": {
                "add":_("Add New Host"),
                "certificate":_("Host Certificate"),
                "cn":_("Host Name"),
                "details":_("Host Settings"),
                "enrolled":_("Enrolled?"),
                "enrollment":_("Enrollment"),
                "fqdn":_("Fully Qualified Host Name"),
                "posix":_("Is this a POSIX group?"),
                "status":_("Status"),
                "valid":_("Kerberos Key Present, Host Provisioned"),
                "delete_key_unprovision":_("Delete Key, Unprovision"),
                "missing":_("Kerberos Key Not Present"),
                "enroll_otp":_("Enroll via One-Time-Password"),
                "set_otp":_("Set OTP"),
                "otp_confirmation":_("One-Time-Password has been set."),
                "unprovision_title":_("Unprovisioning ${entity}"),
                "unprovision_confirmation":_("Are you sure you want to unprovision this host?"),
                "unprovision":_("Unprovision"),
                },
            "hostgroup": {
                "add":_("Add Hostgroup"),
                "identity":_("Hostgroup Settings"),
                },
            "krbtpolicy": {
                "identity":_("Kerberos ticket policy"),
                },
            "netgroup": {
                "add":_("Add Netgroup"),
                "identity":_("Netgroup Settings"),
                },
            "permission": {
                "add":_("Add Permission"),
                "identity":_("Identity"),
                "rights":_("Rights"),
                "target":_("Target"),
                "filter":_("Filter"),
                "subtree":_("By Subtree"),
                "targetgroup":_("Target Group"),
                "type":_("Object By Type"),
                "invalid_target":_("Permission with invalid target specification"),
                },
            "privilege": {
                "add":_("Add Privilege"),
                "identity":_("Privilege Settings"),
                },
            "pwpolicy": {
                "add":_("Add Password Policy"),
                "identity":_("Password Policy"),
                },
            "role": {
                "add":_("Add Role"),
                "identity":_("Role Settings"),
                },
            "selfservice": {
                "add":_("Add Self Service Definition"),
                },
            "service": {
                "add":_("Add New Service"),
                "certificate":_("Service Certificate"),
                "details":_("Service Settings"),
                "host":_("Host Name"),
                "provisioning":_("Provisioning"),
                "service":_("Service"),
                "status":_("Status"),
                "valid":_("Kerberos Key Present, Service Provisioned"),
                "delete_key_unprovision":_("Delete Key, Unprovision"),
                "missing":_("Kerberos Key Not Present"),
                "unprovision_title":_("Unprovisioning ${entity}"),
                "unprovision_confirmation":_("Are you sure you want to unprovision this service?"),
                "unprovision":_("Unprovision"),
                },
            "sudocmd": {
                "add":_("Add New SUDO Command"),
                "groups":_("Groups"),
                },
            "sudocmdgroup": {
                "add":_("Add New SUDO Command Group"),
                "commands":_("Commands"),
                },
            "sudorule": {
                "add":_("Add New Rule"),
                "active":_("Active"),
                "inactive":_("Inactive"),
                "allow":_("Allow"),
                "deny":_("Deny"),
                "user":_("Who"),
                "anyone":_("Anyone"),
                "specified_users":_("Specified Users and Groups"),
                "host":_("Access this host"),
                "any_host":_("Any Host"),
                "specified_hosts":_("Specified Hosts and Groups"),
                "command":_("Run Commands"),
                "any_command":_("Any Command"),
                "specified_commands":_("Specified Commands and Groups"),
                "runas":_("As Whom"),
                "any_group":_("Any Group"),
                "specified_groups":_("Specified Groups"),
                "ipaenabledflag":_("Rule status"),
                "external":_("External"),
                },
            "user": {
                "add":_("Add User"),
                "account":_("Account Settings"),
                "contact":_("Contact Settings"),
                "mailing":_("Mailing Address"),
                "employee":_("Employee Information"),
                "misc":_("Misc. Information"),
                "active":_("Active"),
                "deactivate":_("Click to Deactivate"),
                "inactive":_("Inactive"),
                "activate":_("Click to Activate"),
                "error_changing_status":_("Error changing account status"),
                "reset_password":_("Reset Password"),
                "new_password":_("New Password"),
                "repeat_password":_("Repeat Password"),
                "password_change_complete":_("Password change complete"),
                "password_must_match":_("Passwords must match"),
                },
            },
        "buttons":{
            "add":_("Add"),
            "add_and_add_another":_("Add and Add Another"),
            "add_and_edit":_("Add and Edit"),
            "add_and_close":_("Add and Close"),
            "add_many":_("Add Many"),
            "back_to_list":_("Back to List"),
            "cancel": _("Cancel"),
            "close": _("Close"),
            "enroll":_("Enroll"),
            "find": _("Find"),
            "get": _("Get"),
            "issue": _("Issue"),
            "ok": _("OK"),
            "reset":_("Reset"),
            "remove":_("Delete"),
            "restore":_("Restore"),
            "retry":_("Retry"),
            "revoke":_("Revoke"),
            "update":_("Update"),
            "view":_("View"),
            },
        "dialogs":{
            "remove_empty":_("Select ${entity} to be removed."),
            "remove_title":_("Remove ${entity}."),
            "hide_already_enrolled":_("Hide already enrolled."),
            "available":_("Available"),
            "prospective":_("Prospective"),
            },
        "facets":{
            "search":_("Search"),
            "details": _("Settings"),
            },
        "search":{
            "quick_links":_("Quick Links"),
            "select_all":_("Select All"),
            "unselect_all":_("Unselect All"),
            "delete_confirm":_("Are you sure you want to delete selected entries?"),
            "truncated":_(
                "Query returned results than configured size limit will show. " +
                "First ${counter} results shown."),
            },
        "details":{
            "general":_("General"),
            "settings":_("${entity} Settings"),
            "identity":_("Identity Settings"),
            "to_top":_("Back to Top")
            },
        "tabs": {
            "identity":_("Identity"),
            "policy":_("Policy"),
            "audit": _("Audit"),
            "ipaserver":_("IPA Server"),
            "sudo":_("SUDO"),
            "hbac":_("HBAC"),
            "role":_("Role Based Access Control")
            },
        "association":{
            "add":_("Add ${other_entity} into ${entity} ${primary_key}"),
            "member":_("${other_entity} enrolled in ${entity} ${primary_key}"),
            "parent":_("${entity} ${primary_key} is enrolled in the following ${other_entity}"),
            "remove":_("Remove ${other_entity} from ${entity} ${primary_key}"),
            },
        "widget":{
            "validation_error":_("Text does not match field pattern"),
            },
        "ajax":{
            "401":_("Your kerberos ticket is no longer valid. "+
                "Please run kinit and then click 'Retry'. "+
                "If this is your first time running the IPA Web UI "+
                "<a href='/ipa/config/unauthorized.html'>"+
                "follow these directions</a> to configure your browser.")
            },
        "dirty":_("This page has unsaved changes. Please save or revert."),
        }
    has_output = (
        Output('messages', dict, doc=_('Dict of I18N messages')),
    )
    def execute(self):
        return dict([("messages",json_serialize(self.messages))])

    def output_for_cli(self, textui, result, *args, **options):
        print json.dumps(result, default=json_serialize)


api.register(i18n_messages)