aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--license-generator/Cargo.lock50
-rw-r--r--license-generator/Cargo.toml1
-rw-r--r--license-generator/src/errors.rs2
-rw-r--r--license-generator/src/lib.rs2
-rw-r--r--license-generator/src/zip.rs48
5 files changed, 103 insertions, 0 deletions
diff --git a/license-generator/Cargo.lock b/license-generator/Cargo.lock
index 11725de..368e602 100644
--- a/license-generator/Cargo.lock
+++ b/license-generator/Cargo.lock
@@ -114,6 +114,24 @@ version = "1.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
+name = "bzip2"
+version = "0.3.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "bzip2-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "bzip2-sys"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "cc"
version = "1.0.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -294,6 +312,7 @@ dependencies = [
"sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"simplelog 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "zip 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -348,6 +367,15 @@ dependencies = [
]
[[package]]
+name = "msdos_time"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "mysql"
version = "14.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -505,6 +533,11 @@ dependencies = [
]
[[package]]
+name = "podio"
+version = "0.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+
+[[package]]
name = "proc-macro2"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -805,6 +838,18 @@ dependencies = [
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
]
+[[package]]
+name = "zip"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "bzip2 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "flate2 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "msdos_time 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
[metadata]
"checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c"
"checksum aho-corasick 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9a933f4e58658d7b12defcf96dc5c720f20832deebe3e0a19efd3b6aaeeb9e"
@@ -821,6 +866,8 @@ dependencies = [
"checksum build_const 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "39092a32794787acd8525ee150305ff051b0aa6cc2abaf193924f5ab05425f39"
"checksum byte-tools 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "560c32574a12a89ecd91f5e742165893f86e3ab98d21f8ea548658eb9eef5f40"
"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d"
+"checksum bzip2 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "42b7c3cbf0fa9c1b82308d57191728ca0256cb821220f4e2fd410a72ade26e3b"
+"checksum bzip2-sys 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2c5162604199bbb17690ede847eaa6120a3f33d5ab4dcc8e7c25b16d849ae79b"
"checksum cc 1.0.25 (registry+https://github.com/rust-lang/crates.io-index)" = "f159dfd43363c4d08055a07703eb7a3406b0dac4d0584d96965a3262db3c9d16"
"checksum cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "082bb9b28e00d3c9d39cc03e64ce4cea0f1bb9b3fde493f0cbc008472d22bdf4"
"checksum checked 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e82b46c41844dee0195a9eb4691446e58848996aa3a70d97f4966b48790bae69"
@@ -850,6 +897,7 @@ dependencies = [
"checksum miniz-sys 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "0300eafb20369952951699b68243ab4334f4b10a88f411c221d444b36c40e649"
"checksum miniz_oxide 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5ad30a47319c16cde58d0314f5d98202a80c9083b5f61178457403dfb14e509c"
"checksum miniz_oxide_c_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "28edaef377517fd9fe3e085c37d892ce7acd1fbeab9239c5a36eec352d8a8b7e"
+"checksum msdos_time 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aad9dfe950c057b1bfe9c1f2aa51583a8468ef2a5baba2ebbe06d775efeb7729"
"checksum mysql 14.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5e5ed0dfedd681de679b99b1d2a50ebb3858f76a0cd25fcbf16b59f53752981f"
"checksum mysql_common 0.9.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b053d33e0ebaa00dc7a98cf5708cfc50d9ae9d9996799e88f2c1ef980c0ad5"
"checksum named_pipe 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8ed10a5ac4f5f7e5d75552b12c1d5d542debca81e573279dd1e4c19fde6efa6d"
@@ -862,6 +910,7 @@ dependencies = [
"checksum openssl-sys 0.9.39 (registry+https://github.com/rust-lang/crates.io-index)" = "278c1ad40a89aa1e741a1eed089a2f60b18fab8089c3139b542140fc7d674106"
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
"checksum pkg-config 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "676e8eb2b1b4c9043511a9b7bea0915320d7e502b0a079fb03f9635a5252b18c"
+"checksum podio 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "780fb4b6698bbf9cf2444ea5d22411cef2953f0824b98f33cf454ec5615645bd"
"checksum proc-macro2 0.4.20 (registry+https://github.com/rust-lang/crates.io-index)" = "3d7b7eaaa90b4a90a932a9ea6666c95a389e424eff347f0f793979289429feee"
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
"checksum quote 0.6.9 (registry+https://github.com/rust-lang/crates.io-index)" = "63b5829244f52738cfee93b3a165c1911388675be000c888d2fae620dee8fa5b"
@@ -904,3 +953,4 @@ dependencies = [
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
"checksum xml-rs 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c1cb601d29fe2c2ac60a2b2e5e293994d87a1f6fa9687a31a15270f909be9c2"
+"checksum zip 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "36b9e08fb518a65cf7e08a1e482573eb87a2f4f8c6619316612a3c1f162fe822"
diff --git a/license-generator/Cargo.toml b/license-generator/Cargo.toml
index 80c1963..069230c 100644
--- a/license-generator/Cargo.toml
+++ b/license-generator/Cargo.toml
@@ -15,6 +15,7 @@ serde = "1.0.80"
serde_derive = "1.0.80"
simplelog = "0.5.3"
url = "1.7.2"
+zip = "0.4.2"
[workspace]
members = [
diff --git a/license-generator/src/errors.rs b/license-generator/src/errors.rs
index 0799c3e..c7aadc6 100644
--- a/license-generator/src/errors.rs
+++ b/license-generator/src/errors.rs
@@ -1,6 +1,7 @@
use log;
use mysql;
use paddle;
+use zip_lib;
error_chain! {
foreign_links {
@@ -9,6 +10,7 @@ error_chain! {
Log(log::SetLoggerError);
MySql(mysql::error::Error);
+ Zip(zip_lib::result::ZipError);
Paddle(paddle::errors::Error);
}
diff --git a/license-generator/src/lib.rs b/license-generator/src/lib.rs
index 3e8ae4b..11051cc 100644
--- a/license-generator/src/lib.rs
+++ b/license-generator/src/lib.rs
@@ -8,6 +8,7 @@ extern crate paddle;
extern crate rand;
extern crate sha1;
extern crate url;
+extern crate zip as zip_lib;
pub mod database;
@@ -16,3 +17,4 @@ pub mod params;
pub mod purchaser;
pub mod request;
pub mod response;
+pub mod zip;
diff --git a/license-generator/src/zip.rs b/license-generator/src/zip.rs
new file mode 100644
index 0000000..6c08368
--- /dev/null
+++ b/license-generator/src/zip.rs
@@ -0,0 +1,48 @@
+use std::io::{Seek, Write};
+
+use zip_lib as zip;
+
+use errors::*;
+
+pub fn license<W: Write + Seek>(w: W, plist: &[u8]) -> Result<()> {
+ let mut zip = zip::ZipWriter::new(w);
+
+ zip.start_file(
+ "dome-key-license.plist",
+ zip::write::FileOptions::default()
+ )?;
+ zip.write(plist)?;
+ zip.finish()?;
+
+ Ok(())
+}
+
+
+#[cfg(test)]
+mod tests {
+ use std::fs::File;
+
+ use super::license;
+
+ #[test]
+ #[ignore]
+ fn license_produces_a_valid_zip_file() {
+ let file = File::create("/tmp/license.zip").unwrap();
+ let plist = r#"<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>Email</key>
+ <string>user@email.com</string>
+ <key>Name</key>
+ <string>Üsér Diacriticà</string>
+ <key>Signature</key>
+ <data>RIhF/3CgyXzPg2wCQ5LShf6W9khtqPcqUDLAHcAZdOIcoeR7PoOHi15423kxq5jOh1lmcztBoUJFu8mB45MHE0jmmbRw3qK6FJz9Py2gi1XvGOgH3GW713OCvQBE7vfBj4ZriP0+FS18nLfrtM6Xp0mAd1la4DD4oh7d35dlYTY=</data>
+ <key>lowercase key</key>
+ <string>Keys should be sorted case-insensitive</string>
+</dict>
+</plist>"#;
+
+ license(file, plist.as_bytes()).unwrap();
+ }
+}