diff --git a/src/main/java/sockslib/common/SSLConfiguration.java b/src/main/java/sockslib/common/SSLConfiguration.java index ef2c593..434e7b3 100644 --- a/src/main/java/sockslib/common/SSLConfiguration.java +++ b/src/main/java/sockslib/common/SSLConfiguration.java @@ -15,17 +15,12 @@ package sockslib.common; import com.google.common.base.Strings; -import sockslib.utils.PathUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import sockslib.utils.PathUtil; import javax.annotation.Nullable; -import javax.net.ssl.KeyManagerFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLServerSocketFactory; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManagerFactory; -import java.io.File; +import javax.net.ssl.*; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; @@ -34,6 +29,7 @@ import java.util.Properties; import static com.google.common.base.Preconditions.checkNotNull; +import static sockslib.utils.PathUtil.RESOURCE_SEPARATOR; /** * The class SSLConfiguration represents a configuration of SSL. @@ -123,8 +119,8 @@ public static SSLConfiguration load(String filePath) throws FileNotFoundExceptio public static SSLConfiguration loadClassPath(String filePath) throws FileNotFoundException, IOException { checkNotNull(filePath, "Argument [filePath] may not be null"); - if (!filePath.startsWith(File.separator)) { - filePath = File.separator + filePath; + if (!filePath.startsWith(RESOURCE_SEPARATOR)) { + filePath = RESOURCE_SEPARATOR + filePath; } URL url = SSLConfiguration.class.getResource(filePath); if (url == null) { diff --git a/src/main/java/sockslib/utils/PathUtil.java b/src/main/java/sockslib/utils/PathUtil.java index 84d6575..7133aa3 100644 --- a/src/main/java/sockslib/utils/PathUtil.java +++ b/src/main/java/sockslib/utils/PathUtil.java @@ -14,7 +14,6 @@ package sockslib.utils; -import java.io.File; import java.io.FileNotFoundException; import java.net.URL; @@ -27,6 +26,8 @@ */ public class PathUtil { + public static final String RESOURCE_SEPARATOR = "/"; + /** * Returns abstract path. * @@ -37,8 +38,8 @@ public class PathUtil { public static String getAbstractPath(String path) throws FileNotFoundException { if (path != null && path.startsWith("classpath:")) { String classPathValue = path.split(":")[1]; - if (!classPathValue.startsWith(File.separator)) { - classPathValue = File.separator + classPathValue; + if (!classPathValue.startsWith(RESOURCE_SEPARATOR)) { + classPathValue = RESOURCE_SEPARATOR + classPathValue; } URL url = PathUtil.class.getResource(classPathValue);