Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix build under Windows platform #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 5 additions & 9 deletions src/main/java/sockslib/common/SSLConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 <code>SSLConfiguration</code> represents a configuration of SSL.
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/sockslib/utils/PathUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

package sockslib.utils;

import java.io.File;
import java.io.FileNotFoundException;
import java.net.URL;

Expand All @@ -27,6 +26,8 @@
*/
public class PathUtil {

public static final String RESOURCE_SEPARATOR = "/";

/**
* Returns abstract path.
*
Expand All @@ -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);
Expand Down