Krb5Configure { public static void init (String krb5ConfUrlStr) throws IOException, URISyntaxException { URI krb5ConfURI = null; try { krb5ConfURI = new URI(krb5ConfUrlStr); } catch (URISyntaxException e) { if (krb5ConfURI == null){ throw new URISyntaxException("Bad syntax for URL.", krb5ConfUrlStr); } } System.out.println(krb5ConfURI.getSchemeSpecificPart()); krb5ConfTmpOutputStr = System.getProperty("kerb.krb5Conf.tmp.path", System.getProperty("java.io.tmpdir") + File.separator + "krb5.conf"); krb5ConfTmpOutputPath = Paths.get(krb5ConfTmpOutputStr); switch(krb5ConfURI.getScheme()){ case "classpathfile": copyFromClasspathFile(krb5ConfURI.getSchemeSpecificPart()); break; case "class": copyFromJar(krb5ConfURI.getSchemeSpecificPart()); break; case "file": krb5ConfTmpOutputStr = krb5ConfURI.getSchemeSpecificPart(); break; case "http": copyFromHttpUri(krb5ConfURI); break; case "https": copyFromHttpUri(krb5ConfURI); break; default: throw new URISyntaxException("Unsupported protocol.", krb5ConfUrlStr); } System.setProperty("java.security.krb5.conf", krb5ConfTmpOutputStr); LOG.debug("Using krb5.conf: " + krb5ConfUrlStr + " storing at location: " + krb5ConfTmpOutputStr); }  static void init(String krb5ConfUrlStr);  }
@Test public void classPathURL() { try { Krb5Configure.init("classpath:krb5.conf"); } catch (Exception e) { e.printStackTrace(); } String krb5ConfTmpOutput = System.getProperty("kerb.krb5Conf.tmp.path", System.getProperty("java.io.tmpdir") + File.separator + "krb5.conf"); assertEquals(krb5ConfTmpOutput, System.getProperty("java.security.krb5.conf")); File f = new File(System.getProperty("java.security.krb5.conf")); assertTrue(f.exists() && !f.isDirectory()); }