[gnome-keyring] gcr: Add better xdg-mime files for identifying crypto related file types



commit dea26785fa21607a399207133c25f0bac5eefb80
Author: Stef Walter <stefw collabora co uk>
Date:   Mon Aug 22 15:39:19 2011 +0200

    gcr: Add better xdg-mime files for identifying crypto related file types
    
     * Add hook up gcr-viewer to view most of those types.
     * Rename test file extensions to match the proper ones

 configure.ac                                       |    9 ++
 gcr/.gitignore                                     |    2 +
 gcr/Makefile.am                                    |   31 ++++
 gcr/gcr-crypto-types.xml                           |  151 ++++++++++++++++++++
 gcr/gcr-viewer.desktop.in.in                       |   10 ++
 ...kcs8-PBE-MD5-DES.key => der-key-PBE-MD5-DES.p8} |  Bin 677 -> 677 bytes
 ...-PBE-SHA1-3DES.key => der-key-PBE-SHA1-3DES.p8} |  Bin 678 -> 678 bytes
 ...s8-PBE-SHA1-DES.key => der-key-PBE-SHA1-DES.p8} |  Bin 677 -> 677 bytes
 ...-SHA1-RC2-40.key => der-key-PBE-SHA1-RC2-40.p8} |  Bin 678 -> 678 bytes
 ...HA1-RC4-128.key => der-key-PBE-SHA1-RC4-128.p8} |  Bin 673 -> 673 bytes
 .../files/{der-pkcs8-dsa.key => der-key-dsa.p8}    |  Bin 335 -> 335 bytes
 ...rypted-pkcs5.key => der-key-encrypted-pkcs5.p8} |  Bin 677 -> 677 bytes
 .../{der-pkcs8-v2-des.key => der-key-v2-des.p8}    |  Bin 711 -> 711 bytes
 .../{der-pkcs8-v2-des3.key => der-key-v2-des3.p8}  |  Bin 714 -> 714 bytes
 gcr/tests/files/{der-pkcs8.key => der-key.p8}      |  Bin 635 -> 635 bytes
 ...kcs8-PBE-MD5-DES.key => der-key-PBE-MD5-DES.p8} |  Bin 677 -> 677 bytes
 ...-PBE-SHA1-3DES.key => der-key-PBE-SHA1-3DES.p8} |  Bin 678 -> 678 bytes
 ...s8-PBE-SHA1-DES.key => der-key-PBE-SHA1-DES.p8} |  Bin 677 -> 677 bytes
 ...-SHA1-RC2-40.key => der-key-PBE-SHA1-RC2-40.p8} |  Bin 678 -> 678 bytes
 ...HA1-RC4-128.key => der-key-PBE-SHA1-RC4-128.p8} |  Bin 673 -> 673 bytes
 .../files/{der-pkcs8-dsa.key => der-key-dsa.p8}    |  Bin 335 -> 335 bytes
 ...rypted-pkcs5.key => der-key-encrypted-pkcs5.p8} |  Bin 677 -> 677 bytes
 .../{der-pkcs8-v2-des.key => der-key-v2-des.p8}    |  Bin 711 -> 711 bytes
 .../{der-pkcs8-v2-des3.key => der-key-v2-des3.p8}  |  Bin 714 -> 714 bytes
 .../gkm/tests/files/{der-pkcs8.key => der-key.p8}  |  Bin 635 -> 635 bytes
 pkcs11/gkm/tests/test-data-der.c                   |    4 +-
 26 files changed, 205 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 03328fe..542aeb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -667,6 +667,14 @@ if test "$p11_tests_status" = "yes"; then
 fi
 
 # ----------------------------------------------------------------------
+# mime-database
+
+AC_ARG_ENABLE(update-mime,
+	AC_HELP_STRING([--disable-update-mime],
+	[don't run update-mime-database utility (useful for packages) ]))
+AM_CONDITIONAL(WITH_UPDATE_MIME, test "$enable_update_mime" != "no")
+
+# ----------------------------------------------------------------------
 
 GCK_LT_RELEASE=$GCK_CURRENT:$GCK_REVISION:$GCK_AGE
 AC_SUBST(GCK_LT_RELEASE)
@@ -733,6 +741,7 @@ gck/gck.pc
 gck/Makefile
 gck/tests/Makefile
 gcr/gcr.pc
+gcr/gcr-viewer.desktop.in
 gcr/Makefile
 gcr/icons/Makefile
 gcr/icons/16x16/Makefile
diff --git a/gcr/.gitignore b/gcr/.gitignore
index 680871e..08cae46 100644
--- a/gcr/.gitignore
+++ b/gcr/.gitignore
@@ -1,3 +1,5 @@
 /gcr.pc
 /gcr-0.pc
 /gcr-3.pc
+/gcr-viewer.desktop
+/gcr-viewer.desktop.in
diff --git a/gcr/Makefile.am b/gcr/Makefile.am
index a5a57e8..201e515 100644
--- a/gcr/Makefile.am
+++ b/gcr/Makefile.am
@@ -178,6 +178,32 @@ pkgconfig_DATA = gcr-$(GCR_MAJOR).pc
 gcr-$(GCR_MAJOR).pc: gcr.pc
 	cp gcr.pc gcr-$(GCR_MAJOR).pc
 
+# ----------------------------------------------------------------
+# SYSTEM INTEGRATION
+
+# The new mime system
+mimedir = $(datadir)/mime/packages
+mime_DATA = gcr-crypto-types.xml
+
+if WITH_UPDATE_MIME
+install-data-local:
+	mkdir -p $(mimedir)
+	update-mime-database $(datadir)/mime/
+
+uninstall-local:
+	update-mime-database $(datadir)/mime/
+else
+install-data-local:
+
+uninstall-local:
+
+endif
+
+desktopdir = $(datadir)/applications
+desktop_in_in_files = gcr-viewer.desktop.in.in
+desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
+desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
+ INTLTOOL_DESKTOP_RULE@
 
 # ----------------------------------------------------------------
 # TOOLS
@@ -218,6 +244,9 @@ EXTRA_DIST = \
 	gcr-enum-types.h.template \
 	gcr-enum-types.c.template \
 	gcr.symbols
+	$(desktop_in_in_files) \
+	$(desktop_in_files) \
+	$(desktop_DATA)
 
 CLEANFILES = \
 	$(BUILT_SOURCES) \
@@ -226,6 +255,8 @@ CLEANFILES = \
 	gcr-expected.abi
 
 DISTCLEANFILES = \
+	$(desktop_in_files) \
+	$(desktop_DATA) \
 	$(pkgconfig_DATA)
 
 symbols: libgcr-$(VERSION).symbols
diff --git a/gcr/gcr-crypto-types.xml b/gcr/gcr-crypto-types.xml
new file mode 100644
index 0000000..b911ccd
--- /dev/null
+++ b/gcr/gcr-crypto-types.xml
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info";>
+
+	<!-- Non standard: Common practice -->
+	<mime-type type="application/x-pem-file">
+		<comment>Openssl PEM format</comment>
+		<acronym>PEM</acronym>
+		<sub-class-of type="text/plain"/>
+		<glob weight="50" pattern="*.pem"/>
+	</mime-type>
+
+	<!--  Defined in: http://www.ietf.org/rfc/rfc2585.txt -->
+	<mime-type type="application/pkix-cert">
+		<comment>X.509 Certificate</comment>
+		<glob weight="75" pattern="*.cer"/>
+
+		<!-- Non standard: Common practice -->
+		<glob weight="55" pattern="*.crt"/>
+		<glob weight="55" pattern="*.cert"/>
+
+		<!-- Non standard: Common practice -->
+		<alias type="application/x-x509-ca-cert"/>
+		<alias type="application/x-x509-user-cert"/>
+	</mime-type>
+
+	<!-- Non standard: OpenSSL PEM format -->
+	<mime-type type="application/pkix-cert+pem">
+		<comment>X.509 Certificate in PEM format</comment>
+		<sub-class-of type="application/x-pem-file"/>
+		<magic priority="75">
+			<match type="string" value="-----BEGIN CERTIFICATE-----" offset="0"/>
+		</magic>
+	</mime-type>
+
+	<!-- Defined in: http://www.ietf.org/rfc/rfc2585.txt -->
+	<mime-type type="application/pkix-crl">
+		<comment>Certificate Revocation List</comment>
+		<acronym>CRL</acronym>
+		<expanded-acronym>Certificate Revocation List</expanded-acronym>
+		<glob weight="75" pattern="*.crl"/>
+	</mime-type>
+
+	<!-- Non standard: OpenSSL PEM format -->
+	<mime-type type="application/pkix-crl+pem">
+		<comment>Certificate Revocation List in PEM format</comment>
+		<sub-class-of type="application/x-pem-file"/>
+		<magic priority="75">
+			<match type="string" value="-----BEGIN X509 CRL-----" offset="0"/>
+		</magic>
+	</mime-type>
+
+	<!-- Non standard: Common practice -->
+	<mime-type type="application/x-pkcs12">
+		<comment>PKCS#12 Personal Key and Certificates</comment>
+		<acronym>PKCS#12</acronym>
+		<glob weight="75" pattern="*.p12"/>
+
+		<!-- Non standard: Microsoft practice -->
+		<glob weight="55" pattern="*.pfx"/>
+
+		<!-- Non standard: Rare practice, unclear this actually got into a spec -->
+		<alias type="application/pkcs12"/>
+	</mime-type>
+
+	<!-- Non standard: OpenSSL PEM format -->
+	<mime-type type="application/pkcs12+pem">
+		<comment>PKCS#12 Personal Key and Certificates in PEM format</comment>
+		<sub-class-of type="application/x-pem-file"/>
+		<magic priority="75">
+			<match type="string" value="-----BEGIN PKCS12-----" offset="0"/>
+		</magic>
+	</mime-type>
+
+	<!-- Defined in: http://www.ietf.org/rfc/rfc5958.txt -->
+	<mime-type type="application/pkcs8">
+		<comment>PKCS#8 Personal Key</comment>
+		<acronym>PKCS#8</acronym>
+		<glob weight="75" pattern="*.p8"/>
+
+		<!-- Non standard: Gnome keyring practice -->
+		<glob weight="55" pattern="*.pkcs8"/>
+	</mime-type>
+
+	<!-- Non standard: OpenSSL PEM format -->
+	<mime-type type="application/pkcs8+pem">
+		<comment>PKCS#8 Personal Key in PEM format</comment>
+		<sub-class-of type="application/x-pem-file"/>
+		<magic priority="75">
+			<match type="string" value="-----BEGIN PRIVATE KEY-----" offset="0"/>
+			<match type="string" value="-----BEGIN ENCRYPTED PRIVATE KEY-----" offset="0"/>
+		</magic>
+	</mime-type>
+
+	<!-- Defined in: http://www.ietf.org/rfc/rfc2311.txt -->
+	<mime-type type="application/pkcs7-mime">
+		<comment>PKCS#7 Message and Certificates</comment>
+		<acronym>PKCS#7</acronym>
+		<glob pattern="*.p7c"/>
+		<glob pattern="*.p7m"/>
+
+		<!-- Not standard: Microsoft practice -->
+		<glob pattern="*.spc"/>
+		<glob pattern="*.p7b"/>
+
+		<!-- Non standard: Microsoft practice -->
+		<alias type="application/x-pkcs7-certificates"/>
+	</mime-type>
+
+	<!-- Non standard: OpenSSL PEM format -->
+	<mime-type type="application/pkcs7-mime+pem">
+		<comment>PKCS#7 Message and Certificates in PEM format</comment>
+		<sub-class-of type="application/x-pem-file"/>
+		<magic priority="75">
+			<match type="string" value="-----BEGIN PKCS7-----" offset="0"/>
+		</magic>
+	</mime-type>
+
+	<!-- Defined in http://www.ietf.org/rfc/rfc2311.txt -->
+	<mime-type type="application/pkcs7-signature">
+		<comment>PKCS#7 Signature</comment>
+		<acronym>PKCS#7</acronym>
+		<glob pattern="*.p7s"/>
+	</mime-type>
+
+	<!-- Defined in http://www.ietf.org/rfc/rfc2311.txt -->
+	<mime-type type="application/pkcs10">
+		<comment>PKCS#10 Certificate Request</comment>
+		<acronym>PKCS#10</acronym>
+		<glob pattern="*.p10"/>
+	</mime-type>
+
+	<!-- Non standard: OpenSSL PEM format -->
+	<mime-type type="application/pkcs10+pem">
+		<comment>PKCS#10 Certificate Request in PEM format</comment>
+		<sub-class-of type="application/x-pem-file"/>
+		<magic priority="75">
+			<match type="string" value="-----BEGIN CERTIFICATE REQUEST-----" offset="0"/>
+			<match type="string" value="-----BEGIN NEW CERTIFICATE REQUEST-----" offset="0"/>
+		</magic>
+	</mime-type>
+
+	<!-- Non standard: OpenSSL PEM format -->
+	<mime-type type="application/x-pem-key">
+		<comment>Private Key in PEM format</comment>
+		<sub-class-of type="application/x-pem-file"/>
+		<magic priority="75">
+			<match type="string" value="-----BEGIN RSA PRIVATE KEY-----" offset="0"/>
+			<match type="string" value="-----BEGIN DSA PRIVATE KEY-----" offset="0"/>
+		</magic>
+	</mime-type>
+</mime-info>
diff --git a/gcr/gcr-viewer.desktop.in.in b/gcr/gcr-viewer.desktop.in.in
new file mode 100644
index 0000000..6cd913a
--- /dev/null
+++ b/gcr/gcr-viewer.desktop.in.in
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Name=View file
+MimeType=application/pkcs12;application/pkcs12+pem;application/pkcs7-mime;application/pkcs7-mime+pem;application/pkcs8;application/pkcs8+pem;application/pkix-cert;application/pkix-cert+pem;application/pkix-crl;application/pkix-crl+pem;application/x-pem-file;application/x-pem-key;application/x-pkcs12;application/x-pkcs7-certificates;application/x-x509-ca-cert;application/x-x509-user-cert;
+Exec=gcr-viewer
+Type=Application
+Terminal=false
+NoDisplay=true
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-keyring
+X-GNOME-Bugzilla-Component=gcr
\ No newline at end of file
diff --git a/gcr/tests/files/der-pkcs8-PBE-MD5-DES.key b/gcr/tests/files/der-key-PBE-MD5-DES.p8
similarity index 100%
rename from gcr/tests/files/der-pkcs8-PBE-MD5-DES.key
rename to gcr/tests/files/der-key-PBE-MD5-DES.p8
diff --git a/gcr/tests/files/der-pkcs8-PBE-SHA1-3DES.key b/gcr/tests/files/der-key-PBE-SHA1-3DES.p8
similarity index 100%
rename from gcr/tests/files/der-pkcs8-PBE-SHA1-3DES.key
rename to gcr/tests/files/der-key-PBE-SHA1-3DES.p8
diff --git a/gcr/tests/files/der-pkcs8-PBE-SHA1-DES.key b/gcr/tests/files/der-key-PBE-SHA1-DES.p8
similarity index 100%
rename from gcr/tests/files/der-pkcs8-PBE-SHA1-DES.key
rename to gcr/tests/files/der-key-PBE-SHA1-DES.p8
diff --git a/gcr/tests/files/der-pkcs8-PBE-SHA1-RC2-40.key b/gcr/tests/files/der-key-PBE-SHA1-RC2-40.p8
similarity index 100%
rename from gcr/tests/files/der-pkcs8-PBE-SHA1-RC2-40.key
rename to gcr/tests/files/der-key-PBE-SHA1-RC2-40.p8
diff --git a/gcr/tests/files/der-pkcs8-PBE-SHA1-RC4-128.key b/gcr/tests/files/der-key-PBE-SHA1-RC4-128.p8
similarity index 100%
rename from gcr/tests/files/der-pkcs8-PBE-SHA1-RC4-128.key
rename to gcr/tests/files/der-key-PBE-SHA1-RC4-128.p8
diff --git a/gcr/tests/files/der-pkcs8-dsa.key b/gcr/tests/files/der-key-dsa.p8
similarity index 100%
rename from gcr/tests/files/der-pkcs8-dsa.key
rename to gcr/tests/files/der-key-dsa.p8
diff --git a/gcr/tests/files/der-pkcs8-encrypted-pkcs5.key b/gcr/tests/files/der-key-encrypted-pkcs5.p8
similarity index 100%
rename from gcr/tests/files/der-pkcs8-encrypted-pkcs5.key
rename to gcr/tests/files/der-key-encrypted-pkcs5.p8
diff --git a/gcr/tests/files/der-pkcs8-v2-des.key b/gcr/tests/files/der-key-v2-des.p8
similarity index 100%
rename from gcr/tests/files/der-pkcs8-v2-des.key
rename to gcr/tests/files/der-key-v2-des.p8
diff --git a/gcr/tests/files/der-pkcs8-v2-des3.key b/gcr/tests/files/der-key-v2-des3.p8
similarity index 100%
rename from gcr/tests/files/der-pkcs8-v2-des3.key
rename to gcr/tests/files/der-key-v2-des3.p8
diff --git a/gcr/tests/files/der-pkcs8.key b/gcr/tests/files/der-key.p8
similarity index 100%
rename from gcr/tests/files/der-pkcs8.key
rename to gcr/tests/files/der-key.p8
diff --git a/pkcs11/gkm/tests/files/der-pkcs8-PBE-MD5-DES.key b/pkcs11/gkm/tests/files/der-key-PBE-MD5-DES.p8
similarity index 100%
rename from pkcs11/gkm/tests/files/der-pkcs8-PBE-MD5-DES.key
rename to pkcs11/gkm/tests/files/der-key-PBE-MD5-DES.p8
diff --git a/pkcs11/gkm/tests/files/der-pkcs8-PBE-SHA1-3DES.key b/pkcs11/gkm/tests/files/der-key-PBE-SHA1-3DES.p8
similarity index 100%
rename from pkcs11/gkm/tests/files/der-pkcs8-PBE-SHA1-3DES.key
rename to pkcs11/gkm/tests/files/der-key-PBE-SHA1-3DES.p8
diff --git a/pkcs11/gkm/tests/files/der-pkcs8-PBE-SHA1-DES.key b/pkcs11/gkm/tests/files/der-key-PBE-SHA1-DES.p8
similarity index 100%
rename from pkcs11/gkm/tests/files/der-pkcs8-PBE-SHA1-DES.key
rename to pkcs11/gkm/tests/files/der-key-PBE-SHA1-DES.p8
diff --git a/pkcs11/gkm/tests/files/der-pkcs8-PBE-SHA1-RC2-40.key b/pkcs11/gkm/tests/files/der-key-PBE-SHA1-RC2-40.p8
similarity index 100%
rename from pkcs11/gkm/tests/files/der-pkcs8-PBE-SHA1-RC2-40.key
rename to pkcs11/gkm/tests/files/der-key-PBE-SHA1-RC2-40.p8
diff --git a/pkcs11/gkm/tests/files/der-pkcs8-PBE-SHA1-RC4-128.key b/pkcs11/gkm/tests/files/der-key-PBE-SHA1-RC4-128.p8
similarity index 100%
rename from pkcs11/gkm/tests/files/der-pkcs8-PBE-SHA1-RC4-128.key
rename to pkcs11/gkm/tests/files/der-key-PBE-SHA1-RC4-128.p8
diff --git a/pkcs11/gkm/tests/files/der-pkcs8-dsa.key b/pkcs11/gkm/tests/files/der-key-dsa.p8
similarity index 100%
rename from pkcs11/gkm/tests/files/der-pkcs8-dsa.key
rename to pkcs11/gkm/tests/files/der-key-dsa.p8
diff --git a/pkcs11/gkm/tests/files/der-pkcs8-encrypted-pkcs5.key b/pkcs11/gkm/tests/files/der-key-encrypted-pkcs5.p8
similarity index 100%
rename from pkcs11/gkm/tests/files/der-pkcs8-encrypted-pkcs5.key
rename to pkcs11/gkm/tests/files/der-key-encrypted-pkcs5.p8
diff --git a/pkcs11/gkm/tests/files/der-pkcs8-v2-des.key b/pkcs11/gkm/tests/files/der-key-v2-des.p8
similarity index 100%
rename from pkcs11/gkm/tests/files/der-pkcs8-v2-des.key
rename to pkcs11/gkm/tests/files/der-key-v2-des.p8
diff --git a/pkcs11/gkm/tests/files/der-pkcs8-v2-des3.key b/pkcs11/gkm/tests/files/der-key-v2-des3.p8
similarity index 100%
rename from pkcs11/gkm/tests/files/der-pkcs8-v2-des3.key
rename to pkcs11/gkm/tests/files/der-key-v2-des3.p8
diff --git a/pkcs11/gkm/tests/files/der-pkcs8.key b/pkcs11/gkm/tests/files/der-key.p8
similarity index 100%
rename from pkcs11/gkm/tests/files/der-pkcs8.key
rename to pkcs11/gkm/tests/files/der-key.p8
diff --git a/pkcs11/gkm/tests/test-data-der.c b/pkcs11/gkm/tests/test-data-der.c
index 57823ac..ac1ac48 100644
--- a/pkcs11/gkm/tests/test-data-der.c
+++ b/pkcs11/gkm/tests/test-data-der.c
@@ -440,7 +440,7 @@ test_read_all_pkcs8 (Test *test, gconstpointer unused)
 		if (!name)
 			break;
 
-		if (!g_pattern_match_simple ("der-pkcs8-*", name))
+		if (!g_pattern_match_simple ("der-key-*", name))
 			continue;
 
 		path = g_build_filename (SRCDIR "/files", name, NULL);
@@ -467,7 +467,7 @@ test_read_pkcs8_bad_password (Test *test, gconstpointer unused)
 	gchar *data;
 	gsize n_data;
 
-	if (!g_file_get_contents (SRCDIR "/files/der-pkcs8-encrypted-pkcs5.key", &data, &n_data, NULL))
+	if (!g_file_get_contents (SRCDIR "/files/der-key-encrypted-pkcs5.p8", &data, &n_data, NULL))
 		g_assert_not_reached ();
 
 	res = gkm_data_der_read_private_pkcs8 (data, n_data, "wrong password", 4, &sexp);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]