Add custom QZ Tray fork with pairing key authentication
- Custom fork of QZ Tray 2.2.x with certificate validation bypassed - Implemented pairing key (HMAC) authentication as replacement - Modified files: PrintSocketClient.java (certificate check disabled) - New files: PairingAuth.java, PairingConfigDialog.java - Excluded build artifacts (out/, lib/javafx*) from repository - Library JARs included for dependency management
This commit is contained in:
88
tray/assets/signing/sign-message.vue.js
Normal file
88
tray/assets/signing/sign-message.vue.js
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* JavaScript client-side example using jwa
|
||||
*/
|
||||
|
||||
// #########################################################
|
||||
// # WARNING WARNING WARNING #
|
||||
// #########################################################
|
||||
// # #
|
||||
// # This file is intended for demonstration purposes #
|
||||
// # only. #
|
||||
// # #
|
||||
// # It is the SOLE responsibility of YOU, the programmer #
|
||||
// # to prevent against unauthorized access to any signing #
|
||||
// # functions. #
|
||||
// # #
|
||||
// # Organizations that do not protect against un- #
|
||||
// # authorized signing will be black-listed to prevent #
|
||||
// # software piracy. #
|
||||
// # #
|
||||
// # -QZ Industries, LLC #
|
||||
// # #
|
||||
// #########################################################
|
||||
|
||||
import Vue from "vue";
|
||||
|
||||
import qz from "qz-tray";
|
||||
import jwa from "jwa";
|
||||
|
||||
const vue = new Vue({
|
||||
el: "#app",
|
||||
data: {
|
||||
message: "QZ Tray Vue.js Demo"
|
||||
},
|
||||
template: "<div>{{ message }}</div>"
|
||||
}).$mount();
|
||||
|
||||
const rsa512 = jwa("RS512");
|
||||
|
||||
const privateKey = getPrivateKey();
|
||||
qz.security.setSignatureAlgorithm("SHA512"); // Since 2.1
|
||||
qz.security.setSignaturePromise(function (toSign) {
|
||||
return function (resolve, reject) {
|
||||
try {
|
||||
const hexUrl = rsa512.sign(toSign, privateKey);
|
||||
// Crude base64URL to base64 conversion
|
||||
const hex = hexUrl.replace(/_/g, "/").replace(/-/g, "+");
|
||||
resolve(hex);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
const certificate = getCertificate();
|
||||
qz.security.setCertificatePromise((resolve, reject) => {
|
||||
resolve(certificate);
|
||||
});
|
||||
|
||||
function getPrivateKey() {
|
||||
// TODO: Switch to fetch()/AJAX/etc
|
||||
return (
|
||||
"-----BEGIN PRIVATE KEY-----\n" +
|
||||
"..." +
|
||||
"-----END PRIVATE KEY-----"
|
||||
);
|
||||
}
|
||||
|
||||
function getCertificate() {
|
||||
// TODO: Switch to fetch()/AJAX/etc
|
||||
return (
|
||||
"-----BEGIN CERTIFICATE-----\n" +
|
||||
"..." +
|
||||
"-----END CERTIFICATE-----"
|
||||
);
|
||||
}
|
||||
|
||||
qz.websocket
|
||||
.connect()
|
||||
.then(() => {
|
||||
vue.message = "Looking for printers...";
|
||||
return qz.printers.find();
|
||||
})
|
||||
.then((printers) => {
|
||||
vue.message = "Found printers: " + printers;
|
||||
})
|
||||
.catch((err) => {
|
||||
vue.message = err;
|
||||
});
|
||||
Reference in New Issue
Block a user