fsPart = "invalid"; final String foPart = encodeFoPart(fo);
/** * Gets URL with nbfs protocol for passes fo * @param fo * @return url with nbfs protocol * @throws FileStateInvalidException if FileObject somehow corrupted */ static URL getURL(FileObject fo) throws FileStateInvalidException { final String fsPart = encodeFsPart(fo); final String foPart = encodeFoPart(fo); final String host = "nbhost";//NOI18N final String file = combine(fsPart, foPart); // #13038: the URL constructor accepting a handler is a security-sensitive // operation. Sometimes a user class loaded internally (customized bean...), // which has no privileges, needs to make and use an nbfs: URL, since this // may be the URL used by e.g. ClassLoader.getResource for resources. try { return (URL) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { // #30397: the fsPart name cannot be null return new URL(FileURL.PROTOCOL, host, -1, file, FileURL.HANDLER); // NOI18N } }); } catch (PrivilegedActionException pae) { // MalformedURLException is declared but should not happen. IllegalStateException ise = new IllegalStateException(pae.toString()); ExternalUtil.annotate(ise, pae); throw ise; } }
/** * Gets URL with nbfs protocol for passes fo * @param fo * @return url with nbfs protocol * @throws FileStateInvalidException if FileObject somehow corrupted */ static URL getURL(FileObject fo) throws FileStateInvalidException { final String fsPart = encodeFsPart(fo); final String foPart = encodeFoPart(fo); final String host = "nbhost";//NOI18N final String file = combine(fsPart, foPart); // #13038: the URL constructor accepting a handler is a security-sensitive // operation. Sometimes a user class loaded internally (customized bean...), // which has no privileges, needs to make and use an nbfs: URL, since this // may be the URL used by e.g. ClassLoader.getResource for resources. try { return (URL) AccessController.doPrivileged(new PrivilegedExceptionAction() { public Object run() throws Exception { // #30397: the fsPart name cannot be null return new URL(FileURL.PROTOCOL, host, -1, file, FileURL.HANDLER); // NOI18N } }); } catch (PrivilegedActionException pae) { // MalformedURLException is declared but should not happen. IllegalStateException ise = new IllegalStateException(pae.toString()); ExternalUtil.annotate(ise, pae); throw ise; } }