mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-11 01:59:38 +02:00
Reimplement encryption, solve compiler errors
This commit is contained in:
parent
e5cdd89edc
commit
50f8a4f1fe
20 changed files with 497 additions and 234 deletions
|
@ -20,19 +20,8 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.omemo.signal;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import java.util.logging.Level;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smackx.omemo.OmemoManager;
|
||||
import org.jivesoftware.smackx.omemo.OmemoService;
|
||||
import org.jivesoftware.smackx.omemo.OmemoStore;
|
||||
|
@ -73,11 +62,7 @@ public final class SignalOmemoService
|
|||
return new SignalOmemoRatchet(manager, getOmemoStoreBackend());
|
||||
}
|
||||
|
||||
public static void setup()
|
||||
throws InvalidKeyException, XMPPErrorException, NoSuchPaddingException, InvalidAlgorithmParameterException,
|
||||
UnsupportedEncodingException, IllegalBlockSizeException, BadPaddingException, NoSuchAlgorithmException,
|
||||
NoSuchProviderException, SmackException, InterruptedException, CorruptedOmemoKeyException
|
||||
{
|
||||
public static void setup() {
|
||||
if (!LICENSE_ACKNOWLEDGED) {
|
||||
throw new IllegalStateException("smack-omemo-signal is licensed under the terms of the GPLv3. " +
|
||||
"Please be aware that you can only use this library within the terms of the GPLv3. " +
|
||||
|
@ -98,11 +83,7 @@ public final class SignalOmemoService
|
|||
return new SignalCachingOmemoStore();
|
||||
}
|
||||
|
||||
private SignalOmemoService()
|
||||
throws SmackException, InterruptedException, XMPPException.XMPPErrorException, CorruptedOmemoKeyException,
|
||||
NoSuchPaddingException, InvalidAlgorithmParameterException, UnsupportedEncodingException,
|
||||
IllegalBlockSizeException, BadPaddingException, NoSuchAlgorithmException, NoSuchProviderException,
|
||||
java.security.InvalidKeyException {
|
||||
private SignalOmemoService() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
|
|
@ -225,18 +225,19 @@ public class SignalOmemoStoreConnector
|
|||
|
||||
@Override
|
||||
public SignedPreKeyRecord loadSignedPreKey(int i) throws InvalidKeyIdException {
|
||||
return omemoStore.loadOmemoSignedPreKey(getOurDevice(), i);
|
||||
SignedPreKeyRecord signedPreKeyRecord = omemoStore.loadOmemoSignedPreKey(getOurDevice(), i);
|
||||
if (signedPreKeyRecord == null) {
|
||||
throw new InvalidKeyIdException("No signed preKey with id " + i + " found.");
|
||||
}
|
||||
return signedPreKeyRecord;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SignedPreKeyRecord> loadSignedPreKeys() {
|
||||
List<SignedPreKeyRecord> signedPreKeyRecordList = new ArrayList<>();
|
||||
|
||||
TreeMap<Integer, SignedPreKeyRecord> signedPreKeyRecordHashMap =
|
||||
omemoStore.loadOmemoSignedPreKeys(getOurDevice());
|
||||
signedPreKeyRecordList.addAll(signedPreKeyRecordHashMap.values());
|
||||
|
||||
return signedPreKeyRecordList;
|
||||
return new ArrayList<>(signedPreKeyRecordHashMap.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -259,7 +260,7 @@ public class SignalOmemoStoreConnector
|
|||
omemoStore.removeOmemoSignedPreKey(getOurDevice(), i);
|
||||
}
|
||||
|
||||
public static OmemoDevice asOmemoDevice(SignalProtocolAddress address) throws XmppStringprepException {
|
||||
private static OmemoDevice asOmemoDevice(SignalProtocolAddress address) throws XmppStringprepException {
|
||||
return new OmemoDevice(JidCreate.bareFrom(address.getName()), address.getDeviceId());
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.omemo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
|
@ -51,7 +50,7 @@ public class SignalOmemoKeyUtilTest
|
|||
}
|
||||
|
||||
@Parameterized.Parameters
|
||||
public static Collection<Object[]> getParameters() throws IOException {
|
||||
public static Collection<Object[]> getParameters() {
|
||||
return Arrays.asList(new Object[][] {
|
||||
{ new SignalOmemoKeyUtil()}
|
||||
});
|
||||
|
|
|
@ -26,23 +26,11 @@ import static junit.framework.TestCase.assertNotNull;
|
|||
import static junit.framework.TestCase.assertNotSame;
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.security.InvalidAlgorithmParameterException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.NoSuchProviderException;
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
|
||||
import org.jivesoftware.smack.DummyConnection;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.XMPPException;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||
import org.jivesoftware.smack.test.util.TestUtils;
|
||||
import org.jivesoftware.smackx.omemo.element.OmemoElement;
|
||||
import org.jivesoftware.smackx.omemo.exceptions.CorruptedOmemoKeyException;
|
||||
import org.jivesoftware.smackx.omemo.provider.OmemoVAxolotlProvider;
|
||||
import org.jivesoftware.smackx.omemo.signal.SignalOmemoService;
|
||||
|
||||
|
@ -54,12 +42,7 @@ import org.junit.Test;
|
|||
public class SignalOmemoManagerTest extends SmackTestSuite {
|
||||
|
||||
@Test
|
||||
public void instantiationTest()
|
||||
throws CorruptedOmemoKeyException, NoSuchAlgorithmException, UnsupportedEncodingException,
|
||||
InvalidKeyException, InterruptedException, XMPPException.XMPPErrorException, NoSuchPaddingException,
|
||||
BadPaddingException, InvalidAlgorithmParameterException, NoSuchProviderException, IllegalBlockSizeException,
|
||||
SmackException
|
||||
{
|
||||
public void instantiationTest() {
|
||||
SignalOmemoService.acknowledgeLicense();
|
||||
SignalOmemoService.setup();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue