/*jsl:import ipa.js */ /* Authors: * Endi Sukma Dewata * * 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 . */ IPA.cert = {}; IPA.cert.BEGIN_CERTIFICATE = '-----BEGIN CERTIFICATE-----'; IPA.cert.END_CERTIFICATE = '-----END CERTIFICATE-----'; IPA.cert.BEGIN_CERTIFICATE_REQUEST = '-----BEGIN CERTIFICATE REQUEST-----'; IPA.cert.END_CERTIFICATE_REQUEST = '-----END CERTIFICATE REQUEST-----'; IPA.cert.CERTIFICATE_STATUS_MISSING = 0; IPA.cert.CERTIFICATE_STATUS_VALID = 1; IPA.cert.CERTIFICATE_STATUS_REVOKED = 2; IPA.cert.CRL_REASON = [ 'Unspecified', 'Key Compromise', 'CA Compromise', 'Affiliation Changed', 'Superseded', 'Cessation of Operation', 'Certificate Hold', null, 'Remove from CRL', 'Privilege Withdrawn', 'AA Compromise' ]; IPA.cert.parse_dn = function(dn) { var result = {}; if (!dn) return result; // TODO: Use proper LDAP DN parser var rdns = dn.split(','); for (var i=0; i', { readonly: 'yes', style: 'width: 100%; height: 275px;' }).appendTo(that.container); var certificate = that.certificate; if (that.add_pem_delimiters) { certificate = IPA.cert.BEGIN_CERTIFICATE+'\n'+ that.certificate+'\n'+ IPA.cert.END_CERTIFICATE; } textarea.val(certificate); }; return that; }; IPA.cert.revoke_dialog = function(spec) { spec = spec || {}; var that = IPA.dialog(spec); that.width = spec.width || 500; that.height = spec.height || 300; that.revoke = spec.revoke; that.add_button(IPA.messages.buttons.revoke, function() { var values = {}; values['reason'] = that.select.val(); if (that.revoke) { that.revoke(values); } that.close(); }); that.add_button(IPA.messages.buttons.cancel, function() { that.close(); }); that.create = function() { var table = $('').appendTo(that.container); var tr = $('').appendTo(table); var td = $('').appendTo(table); td = $('
').appendTo(tr); td.append(IPA.messages.objects.cert.note+':'); td = $('').appendTo(tr); td.append(IPA.messages.objects.cert.revoke_confirmation); tr = $('
').appendTo(tr); td.append(IPA.messages.objects.cert.reason+':'); td = $('').appendTo(tr); that.select = $('').appendTo(that.container); var tr = $('').appendTo(table); $('').appendTo(table); $('').appendTo(tr); $('').appendTo(table); $('').appendTo(tr); $('').appendTo(table); $('').appendTo(tr); $('').appendTo(table); $('').appendTo(tr); $('').appendTo(table); $('').appendTo(table); $('').appendTo(tr); $('').appendTo(table); $('').appendTo(tr); $('').appendTo(table); $('').appendTo(tr); $('').appendTo(table); $('').appendTo(table); $('').appendTo(tr); $('').appendTo(table); $('').appendTo(tr); $('').appendTo(table); $('').appendTo(table); $('').appendTo(tr); $('').appendTo(table); $('').appendTo(tr); $('
', { 'colspan': 2, 'html': '

'+IPA.messages.objects.cert.issued_to+'

' }).appendTo(tr); tr = $('
'+IPA.messages.objects.cert.common_name+':', { 'html': that.subject.cn }).appendTo(tr); tr = $('
'+IPA.messages.objects.cert.organization+':', { 'html': that.subject.o }).appendTo(tr); tr = $('
'+IPA.messages.objects.cert.organizational_unit+':', { 'html': that.subject.ou }).appendTo(tr); tr = $('
'+IPA.messages.objects.cert.serial_number+':', { 'html': that.serial_number }).appendTo(tr); tr = $('
', { 'colspan': 2, 'html': '

'+IPA.messages.objects.cert.issued_by+'

' }).appendTo(tr); tr = $('
'+IPA.messages.objects.cert.common_name+':', { 'html': that.issuer.cn }).appendTo(tr); tr = $('
'+IPA.messages.objects.cert.organization+':', { 'html': that.issuer.o }).appendTo(tr); tr = $('
'+IPA.messages.objects.cert.organizational_unit+':', { 'html': that.issuer.ou }).appendTo(tr); tr = $('
', { 'colspan': 2, 'html': '

'+IPA.messages.objects.cert.validity+'

' }).appendTo(tr); tr = $('
'+IPA.messages.objects.cert.issued_on+':', { 'html': that.issued_on }).appendTo(tr); tr = $('
'+IPA.messages.objects.cert.expires_on+':', { 'html': that.expires_on }).appendTo(tr); tr = $('
', { 'colspan': 2, 'html': '

'+IPA.messages.objects.cert.fingerprints+'

' }).appendTo(tr); tr = $('
'+IPA.messages.objects.cert.sha1_fingerprint+':', { 'html': that.sha1_fingerprint }).appendTo(tr); tr = $('
'+IPA.messages.objects.cert.md5_fingerprint+':', { 'html': that.md5_fingerprint }).appendTo(tr); }; return that; }; IPA.cert.request_dialog = function(spec) { spec = spec || {}; var that = IPA.dialog(spec); that.width = spec.width || 500; that.height = spec.height || 400; that.request = spec.request; that.add_button(IPA.messages.buttons.issue, function() { var values = {}; var request = that.textarea.val(); request = IPA.cert.BEGIN_CERTIFICATE_REQUEST+'\n'+ $.trim(request)+'\n'+ IPA.cert.END_CERTIFICATE_REQUEST+'\n'; values['request'] = request; if (that.request) { that.request(values); } that.close(); }); that.add_button(IPA.messages.buttons.cancel, function() { that.close(); }); that.create = function() { that.container.append(IPA.messages.objects.cert.enter_csr+':'); that.container.append('
'); that.container.append('
'); that.container.append(IPA.cert.BEGIN_CERTIFICATE_REQUEST); that.container.append('
'); that.textarea = $('