| 281 | ) |
| 282 | |
| 283 | def _pack_jar(self, full_jar_path: str): |
| 284 | garfile = InMemoryZip() |
| 285 | if not os.path.exists(full_jar_path): |
| 286 | raise FileNotFoundError("Jar file not found in {}.".format(full_jar_path)) |
| 287 | if not full_jar_path.endswith(".jar") or not zipfile.is_zipfile(full_jar_path): |
| 288 | raise KeyError( |
| 289 | "{} is not a jar file, please feed your packed jar file to JavaApp.".format( |
| 290 | full_jar_path |
| 291 | ) |
| 292 | ) |
| 293 | tmp_jar_file = open(full_jar_path, "rb") |
| 294 | jar_bytes = tmp_jar_file.read() |
| 295 | if len(jar_bytes) <= 0: |
| 296 | raise KeyError("Expect a non-empty Jar.") |
| 297 | garfile.append("{}".format(full_jar_path.split("/")[-1]), jar_bytes) |
| 298 | return garfile |
| 299 | |
| 300 | def signature(self): |
| 301 | s = hashlib.sha256() |