Refactoring: renamed 'security' to 'cryptography'
This commit is contained in:
parent
de0100e14f
commit
549c8854ed
@ -53,6 +53,7 @@ BitmessageContext ctx = new BitmessageContext.Builder()
|
||||
.messageRepo(new JdbcMessageRepository(jdbcConfig))
|
||||
.nodeRegistry(new MemoryNodeRegistry())
|
||||
.networkHandler(new NetworkNode())
|
||||
.cryptography(new BouncyCryptography())
|
||||
.build();
|
||||
```
|
||||
This creates a simple context using a H2 database that will be created in the user's home directory. Next you'll need to
|
||||
|
@ -2,9 +2,9 @@ uploadArchives {
|
||||
repositories {
|
||||
mavenDeployer {
|
||||
pom.project {
|
||||
name 'Jabit Bouncy Security'
|
||||
artifactId = 'jabit-security-bouncy'
|
||||
description 'The Security implementation using bouncy castle'
|
||||
name 'Jabit Bouncy Cryptography'
|
||||
artifactId = 'jabit-cryptography-bouncy'
|
||||
description 'The Cryptography implementation using bouncy castle'
|
||||
}
|
||||
}
|
||||
}
|
@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ch.dissem.bitmessage.security.bc;
|
||||
package ch.dissem.bitmessage.cryptography.bc;
|
||||
|
||||
import ch.dissem.bitmessage.entity.payload.Pubkey;
|
||||
import ch.dissem.bitmessage.entity.valueobject.PrivateKey;
|
||||
import ch.dissem.bitmessage.ports.AbstractSecurity;
|
||||
import ch.dissem.bitmessage.ports.AbstractCryptography;
|
||||
import org.bouncycastle.asn1.x9.X9ECParameters;
|
||||
import org.bouncycastle.crypto.BufferedBlockCipher;
|
||||
import org.bouncycastle.crypto.CipherParameters;
|
||||
@ -47,14 +47,14 @@ import java.util.Arrays;
|
||||
* As Spongycastle can't be used on the Oracle JVM, and Bouncycastle doesn't work properly on Android (thanks, Google),
|
||||
* this is the Bouncycastle implementation.
|
||||
*/
|
||||
public class BouncySecurity extends AbstractSecurity {
|
||||
public class BouncyCryptography extends AbstractCryptography {
|
||||
private static final X9ECParameters EC_CURVE_PARAMETERS = CustomNamedCurves.getByName("secp256k1");
|
||||
|
||||
static {
|
||||
java.security.Security.addProvider(new BouncyCastleProvider());
|
||||
}
|
||||
|
||||
public BouncySecurity() {
|
||||
public BouncyCryptography() {
|
||||
super("BC");
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import ch.dissem.bitmessage.entity.ObjectMessage;
|
||||
import ch.dissem.bitmessage.entity.payload.GenericPayload;
|
||||
import ch.dissem.bitmessage.ports.MultiThreadedPOWEngine;
|
||||
import ch.dissem.bitmessage.ports.ProofOfWorkEngine;
|
||||
import ch.dissem.bitmessage.security.bc.BouncySecurity;
|
||||
import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
|
||||
import ch.dissem.bitmessage.utils.CallbackWaiter;
|
||||
import ch.dissem.bitmessage.utils.Singleton;
|
||||
import ch.dissem.bitmessage.utils.UnixTime;
|
||||
@ -23,7 +23,7 @@ import static org.mockito.Mockito.when;
|
||||
/**
|
||||
* Created by chris on 19.07.15.
|
||||
*/
|
||||
public class SecurityTest {
|
||||
public class CryptographyTest {
|
||||
public static final byte[] TEST_VALUE = "teststring".getBytes();
|
||||
public static final byte[] TEST_SHA1 = DatatypeConverter.parseHexBinary(""
|
||||
+ "b8473b86d4c2072ca9b08bd28e373e8253e865c4");
|
||||
@ -33,10 +33,10 @@ public class SecurityTest {
|
||||
public static final byte[] TEST_RIPEMD160 = DatatypeConverter.parseHexBinary(""
|
||||
+ "cd566972b5e50104011a92b59fa8e0b1234851ae");
|
||||
|
||||
private static BouncySecurity security;
|
||||
private static BouncyCryptography security;
|
||||
|
||||
public SecurityTest() {
|
||||
security = new BouncySecurity();
|
||||
public CryptographyTest() {
|
||||
security = new BouncyCryptography();
|
||||
Singleton.initialize(security);
|
||||
InternalContext ctx = mock(InternalContext.class);
|
||||
when(ctx.getProofOfWorkEngine()).thenReturn(new MultiThreadedPOWEngine());
|
@ -2,9 +2,9 @@ uploadArchives {
|
||||
repositories {
|
||||
mavenDeployer {
|
||||
pom.project {
|
||||
name 'Jabit Spongy Security'
|
||||
artifactId = 'jabit-security-spongy'
|
||||
description 'The Security implementation using spongy castle (needed for Android)'
|
||||
name 'Jabit Spongy Cryptography'
|
||||
artifactId = 'jabit-cryptography-spongy'
|
||||
description 'The Cryptography implementation using spongy castle (needed for Android)'
|
||||
}
|
||||
}
|
||||
}
|
@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ch.dissem.bitmessage.security.sc;
|
||||
package ch.dissem.bitmessage.cryptography.sc;
|
||||
|
||||
import ch.dissem.bitmessage.entity.payload.Pubkey;
|
||||
import ch.dissem.bitmessage.entity.valueobject.PrivateKey;
|
||||
import ch.dissem.bitmessage.ports.AbstractSecurity;
|
||||
import ch.dissem.bitmessage.ports.AbstractCryptography;
|
||||
import org.spongycastle.asn1.x9.X9ECParameters;
|
||||
import org.spongycastle.crypto.BufferedBlockCipher;
|
||||
import org.spongycastle.crypto.CipherParameters;
|
||||
@ -47,14 +47,14 @@ import java.util.Arrays;
|
||||
* As Spongycastle can't be used on the Oracle JVM, and Bouncycastle doesn't work properly on Android (thanks, Google),
|
||||
* this is the Spongycastle implementation.
|
||||
*/
|
||||
public class SpongySecurity extends AbstractSecurity {
|
||||
public class SpongyCryptography extends AbstractCryptography {
|
||||
private static final X9ECParameters EC_CURVE_PARAMETERS = CustomNamedCurves.getByName("secp256k1");
|
||||
|
||||
static {
|
||||
java.security.Security.addProvider(new BouncyCastleProvider());
|
||||
}
|
||||
|
||||
public SpongySecurity() {
|
||||
public SpongyCryptography() {
|
||||
super("SC");
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ dependencies {
|
||||
compile project(':domain')
|
||||
compile project(':networking')
|
||||
compile project(':repositories')
|
||||
compile project(':security-bc')
|
||||
compile project(':cryptography-bc')
|
||||
compile project(':wif')
|
||||
compile 'org.slf4j:slf4j-simple:1.7.12'
|
||||
compile 'args4j:args4j:2.32'
|
||||
|
@ -23,7 +23,7 @@ import ch.dissem.bitmessage.entity.payload.Pubkey;
|
||||
import ch.dissem.bitmessage.networking.DefaultNetworkHandler;
|
||||
import ch.dissem.bitmessage.ports.MemoryNodeRegistry;
|
||||
import ch.dissem.bitmessage.repository.*;
|
||||
import ch.dissem.bitmessage.security.bc.BouncySecurity;
|
||||
import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -49,7 +49,7 @@ public class Application {
|
||||
.messageRepo(new JdbcMessageRepository(jdbcConfig))
|
||||
.powRepo(new JdbcProofOfWorkRepository(jdbcConfig))
|
||||
.networkHandler(new DefaultNetworkHandler())
|
||||
.security(new BouncySecurity())
|
||||
.cryptography(new BouncyCryptography())
|
||||
.port(48444)
|
||||
.listener(new BitmessageContext.Listener() {
|
||||
@Override
|
||||
|
@ -20,7 +20,7 @@ import ch.dissem.bitmessage.BitmessageContext;
|
||||
import ch.dissem.bitmessage.networking.DefaultNetworkHandler;
|
||||
import ch.dissem.bitmessage.ports.MemoryNodeRegistry;
|
||||
import ch.dissem.bitmessage.repository.*;
|
||||
import ch.dissem.bitmessage.security.bc.BouncySecurity;
|
||||
import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
|
||||
import ch.dissem.bitmessage.wif.WifExporter;
|
||||
import ch.dissem.bitmessage.wif.WifImporter;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
@ -53,7 +53,7 @@ public class Main {
|
||||
.messageRepo(new JdbcMessageRepository(jdbcConfig))
|
||||
.powRepo(new JdbcProofOfWorkRepository(jdbcConfig))
|
||||
.networkHandler(new DefaultNetworkHandler())
|
||||
.security(new BouncySecurity())
|
||||
.cryptography(new BouncyCryptography())
|
||||
.port(48444)
|
||||
.build();
|
||||
|
||||
|
@ -27,5 +27,5 @@ dependencies {
|
||||
compile 'org.slf4j:slf4j-api:1.7.12'
|
||||
testCompile 'junit:junit:4.11'
|
||||
testCompile 'org.mockito:mockito-core:1.10.19'
|
||||
testCompile project(':security-bc')
|
||||
testCompile project(':cryptography-bc')
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ public class BitmessageContext {
|
||||
MessageRepository messageRepo;
|
||||
ProofOfWorkRepository proofOfWorkRepository;
|
||||
ProofOfWorkEngine proofOfWorkEngine;
|
||||
Security security;
|
||||
Cryptography cryptography;
|
||||
MessageCallback messageCallback;
|
||||
CustomCommandHandler customCommandHandler;
|
||||
Listener listener;
|
||||
@ -372,8 +372,8 @@ public class BitmessageContext {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder security(Security security) {
|
||||
this.security = security;
|
||||
public Builder cryptography(Cryptography cryptography) {
|
||||
this.cryptography = cryptography;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ import java.util.TreeSet;
|
||||
public class InternalContext {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(InternalContext.class);
|
||||
|
||||
private final Security security;
|
||||
private final Cryptography cryptography;
|
||||
private final Inventory inventory;
|
||||
private final NodeRegistry nodeRegistry;
|
||||
private final NetworkHandler networkHandler;
|
||||
@ -64,7 +64,7 @@ public class InternalContext {
|
||||
private int connectionLimit;
|
||||
|
||||
public InternalContext(BitmessageContext.Builder builder) {
|
||||
this.security = builder.security;
|
||||
this.cryptography = builder.cryptography;
|
||||
this.inventory = builder.inventory;
|
||||
this.nodeRegistry = builder.nodeRegistry;
|
||||
this.networkHandler = builder.networkHandler;
|
||||
@ -73,7 +73,7 @@ public class InternalContext {
|
||||
this.proofOfWorkRepository = builder.proofOfWorkRepository;
|
||||
this.proofOfWorkService = new ProofOfWorkService();
|
||||
this.proofOfWorkEngine = builder.proofOfWorkEngine;
|
||||
this.clientNonce = security.randomNonce();
|
||||
this.clientNonce = cryptography.randomNonce();
|
||||
this.messageCallback = builder.messageCallback;
|
||||
this.customCommandHandler = builder.customCommandHandler;
|
||||
this.port = builder.port;
|
||||
@ -81,7 +81,7 @@ public class InternalContext {
|
||||
this.connectionTTL = builder.connectionTTL;
|
||||
this.pubkeyTTL = builder.pubkeyTTL;
|
||||
|
||||
Singleton.initialize(security);
|
||||
Singleton.initialize(cryptography);
|
||||
|
||||
// TODO: streams of new identities and subscriptions should also be added. This works only after a restart.
|
||||
for (BitmessageAddress address : addressRepository.getIdentities()) {
|
||||
@ -94,7 +94,7 @@ public class InternalContext {
|
||||
streams.add(1L);
|
||||
}
|
||||
|
||||
init(security, inventory, nodeRegistry, networkHandler, addressRepository, messageRepository,
|
||||
init(cryptography, inventory, nodeRegistry, networkHandler, addressRepository, messageRepository,
|
||||
proofOfWorkRepository, proofOfWorkService, proofOfWorkEngine,
|
||||
messageCallback, customCommandHandler);
|
||||
for (BitmessageAddress identity : addressRepository.getIdentities()) {
|
||||
@ -110,8 +110,8 @@ public class InternalContext {
|
||||
}
|
||||
}
|
||||
|
||||
public Security getSecurity() {
|
||||
return security;
|
||||
public Cryptography getCryptography() {
|
||||
return cryptography;
|
||||
}
|
||||
|
||||
public Inventory getInventory() {
|
||||
@ -203,7 +203,7 @@ public class InternalContext {
|
||||
.payload(identity.getPubkey())
|
||||
.build();
|
||||
response.sign(identity.getPrivateKey());
|
||||
response.encrypt(security.createPublicKey(identity.getPublicDecryptionKey()));
|
||||
response.encrypt(cryptography.createPublicKey(identity.getPublicDecryptionKey()));
|
||||
messageCallback.proofOfWorkStarted(identity.getPubkey());
|
||||
// TODO: remember that the pubkey is just about to be sent, and on which stream!
|
||||
proofOfWorkService.doProofOfWork(response);
|
||||
|
@ -7,7 +7,7 @@ import ch.dissem.bitmessage.entity.PlaintextHolder;
|
||||
import ch.dissem.bitmessage.ports.MessageRepository;
|
||||
import ch.dissem.bitmessage.ports.ProofOfWorkEngine;
|
||||
import ch.dissem.bitmessage.ports.ProofOfWorkRepository;
|
||||
import ch.dissem.bitmessage.ports.Security;
|
||||
import ch.dissem.bitmessage.ports.Cryptography;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -21,7 +21,7 @@ import static ch.dissem.bitmessage.utils.Singleton.security;
|
||||
public class ProofOfWorkService implements ProofOfWorkEngine.Callback, InternalContext.ContextHolder {
|
||||
private final static Logger LOG = LoggerFactory.getLogger(ProofOfWorkService.class);
|
||||
|
||||
private Security security;
|
||||
private Cryptography cryptography;
|
||||
private InternalContext ctx;
|
||||
private ProofOfWorkRepository powRepo;
|
||||
private MessageRepository messageRepo;
|
||||
@ -33,7 +33,7 @@ public class ProofOfWorkService implements ProofOfWorkEngine.Callback, InternalC
|
||||
LOG.info("Doing POW for " + items.size() + " tasks.");
|
||||
for (byte[] initialHash : items) {
|
||||
ProofOfWorkRepository.Item item = powRepo.getItem(initialHash);
|
||||
security.doProofOfWork(item.object, item.nonceTrialsPerByte, item.extraBytes, this);
|
||||
cryptography.doProofOfWork(item.object, item.nonceTrialsPerByte, item.extraBytes, this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,10 +50,10 @@ public class ProofOfWorkService implements ProofOfWorkEngine.Callback, InternalC
|
||||
powRepo.putObject(object, nonceTrialsPerByte, extraBytes);
|
||||
if (object.getPayload() instanceof PlaintextHolder) {
|
||||
Plaintext plaintext = ((PlaintextHolder) object.getPayload()).getPlaintext();
|
||||
plaintext.setInitialHash(security.getInitialHash(object));
|
||||
plaintext.setInitialHash(cryptography.getInitialHash(object));
|
||||
messageRepo.save(plaintext);
|
||||
}
|
||||
security.doProofOfWork(object, nonceTrialsPerByte, extraBytes, this);
|
||||
cryptography.doProofOfWork(object, nonceTrialsPerByte, extraBytes, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -75,7 +75,7 @@ public class ProofOfWorkService implements ProofOfWorkEngine.Callback, InternalC
|
||||
@Override
|
||||
public void setContext(InternalContext ctx) {
|
||||
this.ctx = ctx;
|
||||
this.security = security();
|
||||
this.cryptography = security();
|
||||
this.powRepo = ctx.getProofOfWorkRepository();
|
||||
this.messageRepo = ctx.getMessageRepository();
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
package ch.dissem.bitmessage.entity;
|
||||
|
||||
import ch.dissem.bitmessage.exception.DecryptionFailedException;
|
||||
import ch.dissem.bitmessage.ports.Security;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -22,7 +22,6 @@ import ch.dissem.bitmessage.entity.payload.Pubkey;
|
||||
import ch.dissem.bitmessage.entity.valueobject.InventoryVector;
|
||||
import ch.dissem.bitmessage.entity.valueobject.PrivateKey;
|
||||
import ch.dissem.bitmessage.exception.DecryptionFailedException;
|
||||
import ch.dissem.bitmessage.ports.Security;
|
||||
import ch.dissem.bitmessage.utils.Bytes;
|
||||
import ch.dissem.bitmessage.utils.Encode;
|
||||
|
||||
|
@ -18,7 +18,6 @@ package ch.dissem.bitmessage.entity.payload;
|
||||
|
||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
||||
import ch.dissem.bitmessage.entity.Plaintext;
|
||||
import ch.dissem.bitmessage.ports.Security;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -39,8 +39,8 @@ import static ch.dissem.bitmessage.utils.Numbers.max;
|
||||
/**
|
||||
* Implements everything that isn't directly dependent on either Spongy- or Bouncycastle.
|
||||
*/
|
||||
public abstract class AbstractSecurity implements Security, InternalContext.ContextHolder {
|
||||
public static final Logger LOG = LoggerFactory.getLogger(Security.class);
|
||||
public abstract class AbstractCryptography implements Cryptography, InternalContext.ContextHolder {
|
||||
public static final Logger LOG = LoggerFactory.getLogger(Cryptography.class);
|
||||
private static final SecureRandom RANDOM = new SecureRandom();
|
||||
private static final BigInteger TWO = BigInteger.valueOf(2);
|
||||
private static final BigInteger TWO_POW_64 = TWO.pow(64);
|
||||
@ -49,7 +49,7 @@ public abstract class AbstractSecurity implements Security, InternalContext.Cont
|
||||
private final String provider;
|
||||
private InternalContext context;
|
||||
|
||||
protected AbstractSecurity(String provider) {
|
||||
protected AbstractCryptography(String provider) {
|
||||
this.provider = provider;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import java.security.SecureRandom;
|
||||
* Provides some methods to help with hashing and encryption. All randoms are created using {@link SecureRandom},
|
||||
* which should be secure enough.
|
||||
*/
|
||||
public interface Security {
|
||||
public interface Cryptography {
|
||||
/**
|
||||
* A helper method to calculate SHA-512 hashes. Please note that a new {@link MessageDigest} object is created at
|
||||
* each call (to ensure thread safety), so you shouldn't use this if you need to do many hash calculations in
|
@ -16,23 +16,23 @@
|
||||
|
||||
package ch.dissem.bitmessage.utils;
|
||||
|
||||
import ch.dissem.bitmessage.ports.Security;
|
||||
import ch.dissem.bitmessage.ports.Cryptography;
|
||||
|
||||
/**
|
||||
* Created by chris on 20.07.15.
|
||||
*/
|
||||
public class Singleton {
|
||||
private static Security security;
|
||||
private static Cryptography cryptography;
|
||||
|
||||
public static void initialize(Security security) {
|
||||
public static void initialize(Cryptography cryptography) {
|
||||
synchronized (Singleton.class) {
|
||||
if (Singleton.security == null) {
|
||||
Singleton.security = security;
|
||||
if (Singleton.cryptography == null) {
|
||||
Singleton.cryptography = cryptography;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Security security() {
|
||||
return security;
|
||||
public static Cryptography security() {
|
||||
return cryptography;
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,13 @@
|
||||
|
||||
package ch.dissem.bitmessage.utils;
|
||||
|
||||
import ch.dissem.bitmessage.security.bc.BouncySecurity;
|
||||
import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
|
||||
|
||||
/**
|
||||
* Created by chris on 20.07.15.
|
||||
*/
|
||||
public class TestBase {
|
||||
static {
|
||||
Singleton.initialize(new BouncySecurity());
|
||||
Singleton.initialize(new BouncyCryptography());
|
||||
}
|
||||
}
|
||||
|
@ -32,5 +32,5 @@ dependencies {
|
||||
testCompile 'org.slf4j:slf4j-simple:1.7.12'
|
||||
testCompile 'org.mockito:mockito-core:1.10.19'
|
||||
testCompile project(path: ':domain', configuration: 'testArtifacts')
|
||||
testCompile project(':security-bc')
|
||||
testCompile project(':cryptography-bc')
|
||||
}
|
||||
|
@ -16,5 +16,5 @@ dependencies {
|
||||
testCompile 'org.slf4j:slf4j-simple:1.7.12'
|
||||
testCompile 'org.mockito:mockito-core:1.10.19'
|
||||
testCompile project(path: ':domain', configuration: 'testArtifacts')
|
||||
testCompile project(':security-bc')
|
||||
testCompile project(':cryptography-bc')
|
||||
}
|
@ -22,7 +22,7 @@ import ch.dissem.bitmessage.ports.AddressRepository;
|
||||
import ch.dissem.bitmessage.ports.MessageRepository;
|
||||
import ch.dissem.bitmessage.ports.NetworkHandler;
|
||||
import ch.dissem.bitmessage.ports.ProofOfWorkRepository;
|
||||
import ch.dissem.bitmessage.security.bc.BouncySecurity;
|
||||
import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
|
||||
import ch.dissem.bitmessage.utils.Property;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
@ -59,7 +59,7 @@ public class NetworkHandlerTest {
|
||||
.port(6001)
|
||||
.nodeRegistry(new TestNodeRegistry())
|
||||
.networkHandler(new DefaultNetworkHandler())
|
||||
.security(new BouncySecurity())
|
||||
.cryptography(new BouncyCryptography())
|
||||
.listener(Mockito.mock(BitmessageContext.Listener.class))
|
||||
.build();
|
||||
peer.startup();
|
||||
@ -74,7 +74,7 @@ public class NetworkHandlerTest {
|
||||
.port(6002)
|
||||
.nodeRegistry(new TestNodeRegistry(localhost))
|
||||
.networkHandler(networkHandler)
|
||||
.security(new BouncySecurity())
|
||||
.cryptography(new BouncyCryptography())
|
||||
.listener(Mockito.mock(BitmessageContext.Listener.class))
|
||||
.build();
|
||||
}
|
||||
|
@ -18,5 +18,5 @@ dependencies {
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'com.h2database:h2:1.4.190'
|
||||
testCompile 'org.mockito:mockito-core:1.10.19'
|
||||
testCompile project(':security-bc')
|
||||
testCompile project(':cryptography-bc')
|
||||
}
|
@ -55,7 +55,7 @@ public class JdbcMessageRepositoryTest extends TestBase {
|
||||
addressRepo = new JdbcAddressRepository(config);
|
||||
repo = new JdbcMessageRepository(config);
|
||||
new InternalContext(new BitmessageContext.Builder()
|
||||
.security(security())
|
||||
.cryptography(security())
|
||||
.addressRepo(addressRepo)
|
||||
.messageRepo(repo)
|
||||
);
|
||||
|
@ -18,7 +18,7 @@ package ch.dissem.bitmessage.repository;
|
||||
|
||||
import ch.dissem.bitmessage.InternalContext;
|
||||
import ch.dissem.bitmessage.ports.MultiThreadedPOWEngine;
|
||||
import ch.dissem.bitmessage.security.bc.BouncySecurity;
|
||||
import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
|
||||
import ch.dissem.bitmessage.utils.Singleton;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
@ -29,7 +29,7 @@ import static org.mockito.Mockito.when;
|
||||
*/
|
||||
public class TestBase {
|
||||
static {
|
||||
BouncySecurity security = new BouncySecurity();
|
||||
BouncyCryptography security = new BouncyCryptography();
|
||||
Singleton.initialize(security);
|
||||
InternalContext ctx = mock(InternalContext.class);
|
||||
when(ctx.getProofOfWorkEngine()).thenReturn(new MultiThreadedPOWEngine());
|
||||
|
@ -10,8 +10,8 @@ include 'demo'
|
||||
|
||||
include 'wif'
|
||||
|
||||
include 'security-sc'
|
||||
include 'cryptography-sc'
|
||||
|
||||
include 'security-bc'
|
||||
include 'cryptography-bc'
|
||||
|
||||
include 'extensions'
|
@ -15,5 +15,5 @@ dependencies {
|
||||
compile 'org.ini4j:ini4j:0.5.4'
|
||||
testCompile 'junit:junit:4.11'
|
||||
testCompile 'org.mockito:mockito-core:1.10.19'
|
||||
testCompile project(':security-bc')
|
||||
testCompile project(':cryptography-bc')
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ package ch.dissem.bitmessage.wif;
|
||||
|
||||
import ch.dissem.bitmessage.BitmessageContext;
|
||||
import ch.dissem.bitmessage.ports.*;
|
||||
import ch.dissem.bitmessage.security.bc.BouncySecurity;
|
||||
import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -35,7 +35,7 @@ public class WifExporterTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ctx = new BitmessageContext.Builder()
|
||||
.security(new BouncySecurity())
|
||||
.cryptography(new BouncyCryptography())
|
||||
.networkHandler(mock(NetworkHandler.class))
|
||||
.inventory(mock(Inventory.class))
|
||||
.messageRepo(mock(MessageRepository.class))
|
||||
|
@ -19,7 +19,7 @@ package ch.dissem.bitmessage.wif;
|
||||
import ch.dissem.bitmessage.BitmessageContext;
|
||||
import ch.dissem.bitmessage.entity.BitmessageAddress;
|
||||
import ch.dissem.bitmessage.ports.*;
|
||||
import ch.dissem.bitmessage.security.bc.BouncySecurity;
|
||||
import ch.dissem.bitmessage.cryptography.bc.BouncyCryptography;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -38,7 +38,7 @@ public class WifImporterTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ctx = new BitmessageContext.Builder()
|
||||
.security(new BouncySecurity())
|
||||
.cryptography(new BouncyCryptography())
|
||||
.networkHandler(mock(NetworkHandler.class))
|
||||
.inventory(mock(Inventory.class))
|
||||
.messageRepo(mock(MessageRepository.class))
|
||||
|
Loading…
Reference in New Issue
Block a user