Merge branch 'master' into Development

# Conflicts:
#	common/pom.xml
#	common/src/main/java/io/bitsquare/app/Version.java
#	core/pom.xml
#	core/src/main/java/io/bitsquare/locale/CurrencyUtil.java
#	gui/pom.xml
#	jsocks/pom.xml
#	jtorctl/pom.xml
#	jtorproxy/pom.xml
#	network/pom.xml
#	package/linux/create_32bit_app.sh
#	package/linux/create_64bit_app.sh
#	package/mac/create_app.sh
#	package/windows/Bitsquare.iss
#	package/windows/create_32bit_app.bat
#	package/windows/create_app.bat
#	pom.xml
#	seednode/pom.xml
This commit is contained in:
Manfred Karrer 2016-05-05 13:30:18 +02:00
commit b9dfa0a7a7
53 changed files with 530 additions and 251 deletions

View file

@ -30,7 +30,7 @@ public class Log {
private static SizeBasedTriggeringPolicy triggeringPolicy;
private static Logger logbackLogger;
public static void setup(String fileName, boolean useDetailedLogging) {
public static void setup(String fileName) {
LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
RollingFileAppender appender = new RollingFileAppender();
@ -60,8 +60,8 @@ public class Log {
appender.start();
logbackLogger = loggerContext.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
logbackLogger.setLevel(useDetailedLogging ? Level.TRACE : Level.WARN);
logbackLogger.addAppender(appender);
logbackLogger.setLevel(Level.INFO);
// log errors in separate file
// not working as expected still.... damn logback...
@ -80,6 +80,10 @@ public class Log {
logbackLogger.addAppender(errorAppender);*/
}
public static void setLevel(boolean useDetailedLogging) {
logbackLogger.setLevel(useDetailedLogging ? Level.TRACE : Level.WARN);
}
public static void traceCall() {
if (LoggerFactory.getLogger(Log.class).isTraceEnabled()) {
StackTraceElement stackTraceElement = new Throwable().getStackTrace()[1];

View file

@ -24,7 +24,7 @@ public class Version {
private static final Logger log = LoggerFactory.getLogger(Version.class);
// The application versions
public static final String VERSION = "0.4.3";
public static final String VERSION = "0.4.6";
// The version nr. for the objects sent over the network. A change will break the serialization of old objects.
// If objects are used for both network and database the network version is applied.
@ -81,6 +81,4 @@ public class Version {
", getP2PNetworkId()=" + getP2PMessageVersion() +
'}');
}
}

View file

@ -30,10 +30,15 @@ import org.slf4j.LoggerFactory;
import java.awt.*;
import java.io.*;
import java.lang.reflect.Field;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.security.Permission;
import java.security.PermissionCollection;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.*;
@ -115,7 +120,49 @@ public class Utilities {
}
private static String getOSName() {
return System.getProperty("os.name").toLowerCase();
return System.getProperty("os.name").toLowerCase(Locale.US);
}
public static String getOSArchitecture() {
String osArch = System.getProperty("os.arch");
if (isWindows()) {
// See: Like always windows needs extra treatment
// https://stackoverflow.com/questions/20856694/how-to-find-the-os-bit-type
String arch = System.getenv("PROCESSOR_ARCHITECTURE");
String wow64Arch = System.getenv("PROCESSOR_ARCHITEW6432");
return arch.endsWith("64")
|| wow64Arch != null && wow64Arch.endsWith("64")
? "64" : "32";
} else if (isLinux()) {
return osArch.startsWith("i") ? "32" : "64";
} else {
return osArch.contains("64") ? "64" : osArch;
}
}
public static void printSysInfo() {
log.info("os.name: " + System.getProperty("os.name"));
log.info("os.version: " + System.getProperty("os.version"));
log.info("os.arch: " + System.getProperty("os.arch"));
log.info("sun.arch.data.model: " + getJVMArchitecture());
log.info("JRE: " + System.getProperty("java.runtime.version", "-") + " (" + System.getProperty("java.vendor", "-") + ")");
log.info("JVM: " + System.getProperty("java.vm.version", "-") + " (" + System.getProperty("java.vm.name", "-") + ")");
}
public static String getJVMArchitecture() {
return System.getProperty("sun.arch.data.model");
}
public static boolean isCorrectOSArchitecture() {
boolean result = getOSArchitecture().endsWith(getJVMArchitecture());
if (!result) {
log.warn("System.getProperty(\"os.arch\") " + System.getProperty("os.arch"));
log.warn("System.getenv(\"ProgramFiles(x86)\") " + System.getenv("ProgramFiles(x86)"));
log.warn("System.getenv(\"PROCESSOR_ARCHITECTURE\")" + System.getenv("PROCESSOR_ARCHITECTURE"));
log.warn("System.getenv(\"PROCESSOR_ARCHITEW6432\") " + System.getenv("PROCESSOR_ARCHITEW6432"));
log.warn("System.getProperty(\"sun.arch.data.model\") " + System.getProperty("sun.arch.data.model"));
}
return result;
}
public static void openURI(URI uri) throws IOException {
@ -151,7 +198,7 @@ public class Utilities {
throw new IOException("Failed to open directory: " + directory.toString());
}
}
public static void openWebPage(String target) {
try {
openURI(new URI(target));
@ -373,4 +420,42 @@ public class Utilities {
return false;
}
}
// See: https://stackoverflow.com/questions/1179672/how-to-avoid-installing-unlimited-strength-jce-policy-files-when-deploying-an
public static void removeCryptographyRestrictions() {
if (!isRestrictedCryptography()) {
log.debug("Cryptography restrictions removal not needed");
return;
}
try {
final Class<?> jceSecurity = Class.forName("javax.crypto.JceSecurity");
final Class<?> cryptoPermissions = Class.forName("javax.crypto.CryptoPermissions");
final Class<?> cryptoAllPermission = Class.forName("javax.crypto.CryptoAllPermission");
final Field isRestrictedField = jceSecurity.getDeclaredField("isRestricted");
isRestrictedField.setAccessible(true);
isRestrictedField.set(null, false);
final Field defaultPolicyField = jceSecurity.getDeclaredField("defaultPolicy");
defaultPolicyField.setAccessible(true);
final PermissionCollection defaultPolicy = (PermissionCollection) defaultPolicyField.get(null);
final Field perms = cryptoPermissions.getDeclaredField("perms");
perms.setAccessible(true);
((Map<?, ?>) perms.get(defaultPolicy)).clear();
final Field instance = cryptoAllPermission.getDeclaredField("INSTANCE");
instance.setAccessible(true);
defaultPolicy.add((Permission) instance.get(null));
log.debug("Successfully removed cryptography restrictions");
} catch (Exception e) {
log.warn("Failed to remove cryptography restrictions", e);
}
}
public static boolean isRestrictedCryptography() {
// This simply matches the Oracle JRE, but not OpenJDK.
return "Java(TM) SE Runtime Environment".equals(System.getProperty("java.runtime.name"));
}
}