47 private static final char[] HEX = {
48 '0', '1', '2', '3', '4', '5', '6', '7',
49 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
50 };
51 private static final char[] BAD_CHARS = {
52 '\\', ':', '*', '?', '"', '<', '>', '|'
53 };
54 private static final String[] REPLACEMENT = {
55 "%5C", "%3A", "%2A", "%3F", "%22", "%3C", "%3E", "%7C"
56 };
57
58 private final Path dumpDir;
59
60 public static ProxyClassesDumper getInstance(String path) {
61 if (null == path) {
62 return null;
63 }
64 try {
65 path = path.trim();
66 final Path dir = Paths.get(path.length() == 0 ? "." : path);
67 AccessController.doPrivileged(new PrivilegedAction<Void>() {
68 @Override
69 public Void run() {
70 validateDumpDir(dir);
71 return null;
72 }
73 }, null, new FilePermission("<<ALL FILES>>", "read, write"));
74 return new ProxyClassesDumper(dir);
75 } catch (InvalidPathException ex) {
76 PlatformLogger.getLogger(ProxyClassesDumper.class.getName())
77 .warning("Path " + path + " is not valid - dumping disabled", ex);
78 } catch (IllegalArgumentException iae) {
79 PlatformLogger.getLogger(ProxyClassesDumper.class.getName())
80 .warning(iae.getMessage() + " - dumping disabled");
81 }
82 return null;
83 }
84
85 private ProxyClassesDumper(Path path) {
86 dumpDir = Objects.requireNonNull(path);
87 }
|
47 private static final char[] HEX = {
48 '0', '1', '2', '3', '4', '5', '6', '7',
49 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
50 };
51 private static final char[] BAD_CHARS = {
52 '\\', ':', '*', '?', '"', '<', '>', '|'
53 };
54 private static final String[] REPLACEMENT = {
55 "%5C", "%3A", "%2A", "%3F", "%22", "%3C", "%3E", "%7C"
56 };
57
58 private final Path dumpDir;
59
60 public static ProxyClassesDumper getInstance(String path) {
61 if (null == path) {
62 return null;
63 }
64 try {
65 path = path.trim();
66 final Path dir = Paths.get(path.length() == 0 ? "." : path);
67 AccessController.doPrivileged(new PrivilegedAction<>() {
68 @Override
69 public Void run() {
70 validateDumpDir(dir);
71 return null;
72 }
73 }, null, new FilePermission("<<ALL FILES>>", "read, write"));
74 return new ProxyClassesDumper(dir);
75 } catch (InvalidPathException ex) {
76 PlatformLogger.getLogger(ProxyClassesDumper.class.getName())
77 .warning("Path " + path + " is not valid - dumping disabled", ex);
78 } catch (IllegalArgumentException iae) {
79 PlatformLogger.getLogger(ProxyClassesDumper.class.getName())
80 .warning(iae.getMessage() + " - dumping disabled");
81 }
82 return null;
83 }
84
85 private ProxyClassesDumper(Path path) {
86 dumpDir = Objects.requireNonNull(path);
87 }
|