use of com.atlassian.extras.common.LicenseException in project env-tool-suite by stormning.
the class Version2LicenseDecoder method packLicense.
public static String packLicense(byte[] text, byte[] hash) throws LicenseException {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream dOut = new DataOutputStream(out);
dOut.writeInt(text.length);
dOut.write(text);
dOut.write(hash);
byte[] allData = out.toByteArray();
String result = (new String(Base64.encodeBase64(allData))).trim();
result = result + 'X' + "0" + 2 + Integer.toString(result.length(), 31);
result = split(result);
return result;
} catch (IOException var6) {
throw new LicenseException(var6);
}
}
use of com.atlassian.extras.common.LicenseException in project env-tool-suite by stormning.
the class Version2LicenseDecoder method unzipText.
private Reader unzipText(byte[] licenseText) {
ByteArrayInputStream in = new ByteArrayInputStream(licenseText);
in.skip((long) LICENSE_PREFIX.length);
InflaterInputStream zipIn = new InflaterInputStream(in, new Inflater());
try {
return new InputStreamReader(zipIn, "UTF-8");
} catch (UnsupportedEncodingException var5) {
throw new LicenseException(var5);
}
}
use of com.atlassian.extras.common.LicenseException in project env-tool-suite by stormning.
the class Version2LicenseDecoder method checkAndGetLicenseText.
private byte[] checkAndGetLicenseText(String licenseContent) {
try {
byte[] decodedBytes = Base64.decodeBase64(licenseContent.getBytes());
ByteArrayInputStream in = new ByteArrayInputStream(decodedBytes);
DataInputStream dIn = new DataInputStream(in);
int textLength = dIn.readInt();
byte[] licenseText = new byte[textLength];
dIn.read(licenseText);
byte[] hash = new byte[dIn.available()];
dIn.read(hash);
try {
Signature signature = Signature.getInstance("SHA1withDSA");
signature.initVerify(PUBLIC_KEY);
signature.update(licenseText);
if (!signature.verify(hash)) {
throw new LicenseException("Failed to verify the license.");
} else {
return licenseText;
}
} catch (InvalidKeyException var9) {
throw new LicenseException(var9);
} catch (SignatureException var10) {
throw new LicenseException(var10);
} catch (NoSuchAlgorithmException var11) {
throw new LicenseException(var11);
}
} catch (IOException var12) {
throw new LicenseException(var12);
}
}
use of com.atlassian.extras.common.LicenseException in project env-tool-suite by stormning.
the class Version2LicenseDecoder method loadLicenseConfiguration.
private Properties loadLicenseConfiguration(Reader text) {
try {
Properties props = new Properties();
(new DefaultPropertiesPersister()).load(props, text);
return props;
} catch (IOException var3) {
throw new LicenseException("Could NOT load properties from reader", var3);
}
}
Aggregations