-
Notifications
You must be signed in to change notification settings - Fork 469
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ | |
import org.bouncycastle.openpgp.operator.PBESecretKeyDecryptor; | ||
import org.bouncycastle.openpgp.operator.bc.*; | ||
import org.bouncycastle.openpgp.operator.jcajce.JcaPGPContentVerifierBuilderProvider; | ||
import org.jpos.core.Environment; | ||
import org.jpos.iso.ISOUtil; | ||
import org.jpos.log.evt.License; | ||
import org.jpos.q2.Q2; | ||
|
@@ -45,9 +46,19 @@ public class PGPHelper { | |
private static KeyFingerPrintCalculator fingerPrintCalculator = new BcKeyFingerprintCalculator(); | ||
private static final String PUBRING = "META-INF/.pgp/pubring.asc"; | ||
private static final String SIGNER = "[email protected]"; | ||
private static int node; | ||
static { | ||
if(Security.getProvider("BC") == null) | ||
Security.addProvider(new BouncyCastleProvider()); | ||
|
||
String nodeString = Environment.get("${q2.node:1}"); | ||
Pattern pattern = Pattern.compile("\\d+"); | ||
|
||
node = (nodeString == null || nodeString.isEmpty()) | ||
? 1 | ||
: (pattern.matcher(nodeString).find() | ||
? Integer.parseInt(pattern.matcher(nodeString).group()) | ||
: 1); | ||
} | ||
|
||
private static boolean verifySignature(InputStream in, PGPPublicKey pk) throws IOException, PGPException { | ||
|
@@ -205,7 +216,9 @@ public static int checkLicense() { | |
} | ||
matcher = p2.matcher(s); | ||
if (matcher.find() && matcher.groupCount() == 2) { | ||
rc |= Integer.parseInt(matcher.group(2)); | ||
int n = Integer.parseInt(matcher.group(2)); | ||
node = n >= node ? node : 0; | ||
rc |= n; | ||
} | ||
if (s.contains(h)) { | ||
rc &= 0xEFFFF; | ||
|
@@ -248,6 +261,10 @@ public static String getLicenseeHash() throws IOException, NoSuchAlgorithmExcept | |
return ISOUtil.hexString(hash(getLicensee())); | ||
} | ||
|
||
public static int node () { | ||
return node; | ||
} | ||
|
||
/** | ||
* Simple PGP encryptor between byte[]. | ||
* | ||
|