|
1 | 1 | /*
|
2 |
| - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
27 | 27 |
|
28 | 28 | import java.io.*;
|
29 | 29 | import java.net.UnknownHostException;
|
| 30 | +import java.net.URLClassLoader; |
30 | 31 | import java.security.cert.CertPathValidatorException;
|
31 | 32 | import java.security.cert.PKIXBuilderParameters;
|
32 | 33 | import java.util.*;
|
|
59 | 60 | import sun.security.provider.certpath.CertPathConstraintsParameters;
|
60 | 61 | import sun.security.timestamp.TimestampToken;
|
61 | 62 | import sun.security.tools.KeyStoreUtil;
|
| 63 | +import sun.security.tools.PathList; |
62 | 64 | import sun.security.validator.Validator;
|
63 | 65 | import sun.security.validator.ValidatorException;
|
64 | 66 | import sun.security.x509.*;
|
@@ -152,6 +154,7 @@ public static void main(String args[]) throws Exception {
|
152 | 154 | List<String> providerClasses = null; // list of provider classes
|
153 | 155 | // arguments for provider constructors
|
154 | 156 | HashMap<String,String> providerArgs = new HashMap<>();
|
| 157 | + String pathlist = null; |
155 | 158 | char[] keypass; // private key password
|
156 | 159 | String sigfile; // name of .SF file
|
157 | 160 | String sigalg; // name of signature algorithm
|
@@ -246,7 +249,18 @@ public void run(String args[]) {
|
246 | 249 | }
|
247 | 250 |
|
248 | 251 | if (providerClasses != null) {
|
249 |
| - ClassLoader cl = ClassLoader.getSystemClassLoader(); |
| 252 | + ClassLoader cl; |
| 253 | + if (pathlist != null) { |
| 254 | + String path = System.getProperty("java.class.path"); |
| 255 | + path = PathList.appendPath( |
| 256 | + path, System.getProperty("env.class.path")); |
| 257 | + path = PathList.appendPath(path, pathlist); |
| 258 | + |
| 259 | + URL[] urls = PathList.pathToURLs(path); |
| 260 | + cl = new URLClassLoader(urls); |
| 261 | + } else { |
| 262 | + cl = ClassLoader.getSystemClassLoader(); |
| 263 | + } |
250 | 264 | for (String provClass: providerClasses) {
|
251 | 265 | try {
|
252 | 266 | KeyStoreUtil.loadProviderByClass(provClass,
|
@@ -434,6 +448,9 @@ String[] parseArgs(String args[]) throws Exception {
|
434 | 448 | n += 2;
|
435 | 449 | }
|
436 | 450 | }
|
| 451 | + } else if (collator.compare(flags, "-providerpath") == 0) { |
| 452 | + if (++n == args.length) usageNoArg(); |
| 453 | + pathlist = args[n]; |
437 | 454 | } else if (collator.compare(flags, "-protected") ==0) {
|
438 | 455 | protectedPath = true;
|
439 | 456 | } else if (collator.compare(flags, "-certchain") ==0) {
|
@@ -705,6 +722,9 @@ static void fullusage() {
|
705 | 722 | System.out.println(rb.getString
|
706 | 723 | (".providerArg.option.2"));
|
707 | 724 | System.out.println();
|
| 725 | + System.out.println(rb.getString |
| 726 | + (".providerPath.option")); |
| 727 | + System.out.println(); |
708 | 728 | System.out.println(rb.getString
|
709 | 729 | (".strict.treat.warnings.as.errors"));
|
710 | 730 | System.out.println();
|
|
0 commit comments