public static String getLicensee() { InputStream is = Q2.class.getResourceAsStream(LICENSEE); ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (is != null) { BufferedReader br = new BufferedReader(new InputStreamReader(is)); PrintStream p = new PrintStream(baos); p.println(); p.println(); try { while (br.ready()) p.println(br.readLine()); } catch (Exception e) { e.printStackTrace(p); } } return baos.toString(); }
protected Document encrypt(Document doc) throws GeneralSecurityException, IOException { ByteArrayOutputStream os = new ByteArrayOutputStream(); OutputStreamWriter writer = new OutputStreamWriter(os); XMLOutputter out = new XMLOutputter(Format.getPrettyFormat()); out.output(doc, writer); writer.close(); byte[] crypt = dodes(os.toByteArray(), Cipher.ENCRYPT_MODE); Document secureDoc = new Document(); Element root = new Element(PROTECTED_QBEAN); secureDoc.setRootElement(root); Element secureData = new Element("data"); root.addContent(secureData); secureData.setText(ISOUtil.hexString(crypt)); return secureDoc; }