1 /*
2 * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
440 rb.getString("This.option.is.deprecated") +
441 "-altsignerpath");
442 } else if (collator.compare(flags, "-sectionsonly") ==0) {
443 signManifest = false;
444 } else if (collator.compare(flags, "-internalsf") ==0) {
445 externalSF = false;
446 } else if (collator.compare(flags, "-verify") ==0) {
447 verify = true;
448 } else if (collator.compare(flags, "-verbose") ==0) {
449 verbose = (modifier != null) ? modifier : "all";
450 } else if (collator.compare(flags, "-sigalg") ==0) {
451 if (++n == args.length) usageNoArg();
452 sigalg = args[n];
453 } else if (collator.compare(flags, "-digestalg") ==0) {
454 if (++n == args.length) usageNoArg();
455 digestalg = args[n];
456 } else if (collator.compare(flags, "-certs") ==0) {
457 showcerts = true;
458 } else if (collator.compare(flags, "-strict") ==0) {
459 strict = true;
460 } else if (collator.compare(flags, "-h") == 0 ||
461 collator.compare(flags, "-?") == 0 ||
462 collator.compare(flags, "-help") == 0) {
463 fullusage();
464 } else {
465 System.err.println(
466 rb.getString("Illegal.option.") + flags);
467 usage();
468 }
469 }
470
471 // -certs must always be specified with -verbose
472 if (verbose == null) showcerts = false;
473
474 if (jarfile == null) {
475 System.err.println(rb.getString("Please.specify.jarfile.name"));
476 usage();
477 }
478 if (!verify && alias == null) {
479 System.err.println(rb.getString("Please.specify.alias.name"));
480 usage();
481 }
630 (".protected.keystore.has.protected.authentication.path"));
631 System.out.println();
632 System.out.println(rb.getString
633 (".providerName.name.provider.name"));
634 System.out.println();
635 System.out.println(rb.getString
636 (".add.provider.option"));
637 System.out.println(rb.getString
638 (".providerArg.option.1"));
639 System.out.println();
640 System.out.println(rb.getString
641 (".providerClass.option"));
642 System.out.println(rb.getString
643 (".providerArg.option.2"));
644 System.out.println();
645 System.out.println(rb.getString
646 (".strict.treat.warnings.as.errors"));
647 System.out.println();
648 System.out.println(rb.getString
649 (".conf.url.specify.a.pre.configured.options.file"));
650 System.out.println();
651
652 System.exit(0);
653 }
654
655 void verifyJar(String jarName)
656 throws Exception
657 {
658 boolean anySigned = false; // if there exists entry inside jar signed
659 JarFile jf = null;
660 Map<String,String> digestMap = new HashMap<>();
661 Map<String,PKCS7> sigMap = new HashMap<>();
662 Map<String,String> sigNameMap = new HashMap<>();
663 Map<String,String> unparsableSignatures = new HashMap<>();
664
665 try {
666 jf = new JarFile(jarName, true);
667 Vector<JarEntry> entriesVec = new Vector<>();
668 byte[] buffer = new byte[8192];
669
|
1 /*
2 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
440 rb.getString("This.option.is.deprecated") +
441 "-altsignerpath");
442 } else if (collator.compare(flags, "-sectionsonly") ==0) {
443 signManifest = false;
444 } else if (collator.compare(flags, "-internalsf") ==0) {
445 externalSF = false;
446 } else if (collator.compare(flags, "-verify") ==0) {
447 verify = true;
448 } else if (collator.compare(flags, "-verbose") ==0) {
449 verbose = (modifier != null) ? modifier : "all";
450 } else if (collator.compare(flags, "-sigalg") ==0) {
451 if (++n == args.length) usageNoArg();
452 sigalg = args[n];
453 } else if (collator.compare(flags, "-digestalg") ==0) {
454 if (++n == args.length) usageNoArg();
455 digestalg = args[n];
456 } else if (collator.compare(flags, "-certs") ==0) {
457 showcerts = true;
458 } else if (collator.compare(flags, "-strict") ==0) {
459 strict = true;
460 } else if (collator.compare(flags, "-?") == 0 ||
461 collator.compare(flags, "-h") == 0 ||
462 collator.compare(flags, "--help") == 0 ||
463 // -help: legacy.
464 collator.compare(flags, "-help") == 0) {
465 fullusage();
466 } else {
467 System.err.println(
468 rb.getString("Illegal.option.") + flags);
469 usage();
470 }
471 }
472
473 // -certs must always be specified with -verbose
474 if (verbose == null) showcerts = false;
475
476 if (jarfile == null) {
477 System.err.println(rb.getString("Please.specify.jarfile.name"));
478 usage();
479 }
480 if (!verify && alias == null) {
481 System.err.println(rb.getString("Please.specify.alias.name"));
482 usage();
483 }
632 (".protected.keystore.has.protected.authentication.path"));
633 System.out.println();
634 System.out.println(rb.getString
635 (".providerName.name.provider.name"));
636 System.out.println();
637 System.out.println(rb.getString
638 (".add.provider.option"));
639 System.out.println(rb.getString
640 (".providerArg.option.1"));
641 System.out.println();
642 System.out.println(rb.getString
643 (".providerClass.option"));
644 System.out.println(rb.getString
645 (".providerArg.option.2"));
646 System.out.println();
647 System.out.println(rb.getString
648 (".strict.treat.warnings.as.errors"));
649 System.out.println();
650 System.out.println(rb.getString
651 (".conf.url.specify.a.pre.configured.options.file"));
652 System.out.println();
653 System.out.println(rb.getString
654 (".print.this.help.message"));
655 System.out.println();
656
657 System.exit(0);
658 }
659
660 void verifyJar(String jarName)
661 throws Exception
662 {
663 boolean anySigned = false; // if there exists entry inside jar signed
664 JarFile jf = null;
665 Map<String,String> digestMap = new HashMap<>();
666 Map<String,PKCS7> sigMap = new HashMap<>();
667 Map<String,String> sigNameMap = new HashMap<>();
668 Map<String,String> unparsableSignatures = new HashMap<>();
669
670 try {
671 jf = new JarFile(jarName, true);
672 Vector<JarEntry> entriesVec = new Vector<>();
673 byte[] buffer = new byte[8192];
674
|