Commit b86faa91 authored by narinder Rana's avatar narinder Rana
Browse files

handle exception

parent 8aaf1052
Pipeline #106187 passed with stage
in 4 minutes and 20 seconds
......@@ -91,41 +91,46 @@ class IntegrityVerificationTask(
apkInputStream: BufferedInputStream,
apkSignatureInputStream: InputStream,
publicKeyInputStream: InputStream): Boolean {
try {
var jcaPGPObjectFactory =
JcaPGPObjectFactory(PGPUtil.getDecoderStream(apkSignatureInputStream))
val pgpSignatureList: PGPSignatureList
var jcaPGPObjectFactory =
JcaPGPObjectFactory(PGPUtil.getDecoderStream(apkSignatureInputStream))
val pgpSignatureList: PGPSignatureList
val pgpObject = jcaPGPObjectFactory.nextObject()
if (pgpObject is PGPCompressedData) {
jcaPGPObjectFactory = JcaPGPObjectFactory(pgpObject.dataStream)
pgpSignatureList = jcaPGPObjectFactory.nextObject() as PGPSignatureList
} else {
pgpSignatureList = pgpObject as PGPSignatureList
}
val pgpObject = jcaPGPObjectFactory.nextObject()
if (pgpObject is PGPCompressedData) {
jcaPGPObjectFactory = JcaPGPObjectFactory(pgpObject.dataStream)
pgpSignatureList = jcaPGPObjectFactory.nextObject() as PGPSignatureList
} else {
pgpSignatureList = pgpObject as PGPSignatureList
}
val pgpPublicKeyRingCollection =
PGPPublicKeyRingCollection(
PGPUtil.getDecoderStream(publicKeyInputStream),
JcaKeyFingerprintCalculator())
val pgpPublicKeyRingCollection =
PGPPublicKeyRingCollection(
PGPUtil.getDecoderStream(publicKeyInputStream),
JcaKeyFingerprintCalculator())
val signature = pgpSignatureList.get(0)
val key = pgpPublicKeyRingCollection.getPublicKey(signature.keyID)
val signature = pgpSignatureList.get(0)
val key = pgpPublicKeyRingCollection.getPublicKey(signature.keyID)
signature.init(BcPGPContentVerifierBuilderProvider(), key)
signature.init(BcPGPContentVerifierBuilderProvider(), key)
val buff = ByteArray(1024)
var read = apkInputStream.read(buff)
while (read != -1) {
signature.update(buff, 0, read)
read = apkInputStream.read(buff)
}
val buff = ByteArray(1024)
var read = apkInputStream.read(buff)
while (read != -1) {
signature.update(buff, 0, read)
read = apkInputStream.read(buff)
}
apkInputStream.close()
apkSignatureInputStream.close()
publicKeyInputStream.close()
apkInputStream.close()
apkSignatureInputStream.close()
publicKeyInputStream.close()
return signature.verify()
return signature.verify()
} catch (e: Exception) {
e.printStackTrace()
}
return false;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment