2016-10-14 15:27:20 +02:00
|
|
|
/*
|
2017-01-10 11:40:57 +01:00
|
|
|
* Copyright 2017 OpenMarket Ltd
|
2019-03-14 03:43:56 +01:00
|
|
|
* Copyright 2017-2019 Vector Creations Ltd
|
2016-10-14 15:27:20 +02:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.matrix.olm;
|
|
|
|
|
2016-10-28 10:49:04 +02:00
|
|
|
import java.io.IOException;
|
|
|
|
|
2016-10-18 16:05:28 +02:00
|
|
|
/**
|
2016-10-26 18:15:37 +02:00
|
|
|
* Exception class to identify specific Olm SDK exceptions.
|
2016-10-18 16:05:28 +02:00
|
|
|
*/
|
2016-10-28 10:49:04 +02:00
|
|
|
public class OlmException extends IOException {
|
2016-10-14 15:27:20 +02:00
|
|
|
// exception codes
|
2016-10-18 16:05:28 +02:00
|
|
|
|
2017-01-04 14:35:08 +01:00
|
|
|
public static final int EXCEPTION_CODE_INIT_ACCOUNT_CREATION = 10;
|
2017-01-04 11:46:37 +01:00
|
|
|
|
2017-01-09 10:25:18 +01:00
|
|
|
public static final int EXCEPTION_CODE_ACCOUNT_SERIALIZATION = 100;
|
|
|
|
public static final int EXCEPTION_CODE_ACCOUNT_DESERIALIZATION = 101;
|
|
|
|
public static final int EXCEPTION_CODE_ACCOUNT_IDENTITY_KEYS = 102;
|
|
|
|
public static final int EXCEPTION_CODE_ACCOUNT_GENERATE_ONE_TIME_KEYS = 103;
|
|
|
|
public static final int EXCEPTION_CODE_ACCOUNT_ONE_TIME_KEYS = 104;
|
|
|
|
public static final int EXCEPTION_CODE_ACCOUNT_REMOVE_ONE_TIME_KEYS = 105;
|
|
|
|
public static final int EXCEPTION_CODE_ACCOUNT_MARK_ONE_KEYS_AS_PUBLISHED = 106;
|
|
|
|
public static final int EXCEPTION_CODE_ACCOUNT_SIGN_MESSAGE = 107;
|
2021-09-03 09:59:18 +02:00
|
|
|
public static final int EXCEPTION_CODE_ACCOUNT_GENERATE_FALLBACK_KEY = 108;
|
|
|
|
public static final int EXCEPTION_CODE_ACCOUNT_FALLBACK_KEY = 109;
|
2021-12-02 09:54:42 +01:00
|
|
|
public static final int EXCEPTION_CODE_ACCOUNT_FORGET_FALLBACK_KEY = 110;
|
2017-01-09 10:25:18 +01:00
|
|
|
|
|
|
|
public static final int EXCEPTION_CODE_CREATE_INBOUND_GROUP_SESSION = 200;
|
|
|
|
public static final int EXCEPTION_CODE_INIT_INBOUND_GROUP_SESSION = 201;
|
|
|
|
public static final int EXCEPTION_CODE_INBOUND_GROUP_SESSION_IDENTIFIER = 202;
|
|
|
|
public static final int EXCEPTION_CODE_INBOUND_GROUP_SESSION_DECRYPT_SESSION = 203;
|
2017-01-18 15:33:14 +01:00
|
|
|
public static final int EXCEPTION_CODE_INBOUND_GROUP_SESSION_FIRST_KNOWN_INDEX = 204;
|
|
|
|
public static final int EXCEPTION_CODE_INBOUND_GROUP_SESSION_IS_VERIFIED = 205;
|
|
|
|
public static final int EXCEPTION_CODE_INBOUND_GROUP_SESSION_EXPORT = 206;
|
2017-01-09 10:25:18 +01:00
|
|
|
|
|
|
|
public static final int EXCEPTION_CODE_CREATE_OUTBOUND_GROUP_SESSION = 300;
|
|
|
|
public static final int EXCEPTION_CODE_INIT_OUTBOUND_GROUP_SESSION = 301;
|
|
|
|
public static final int EXCEPTION_CODE_OUTBOUND_GROUP_SESSION_IDENTIFIER = 302;
|
|
|
|
public static final int EXCEPTION_CODE_OUTBOUND_GROUP_SESSION_KEY = 303;
|
|
|
|
public static final int EXCEPTION_CODE_OUTBOUND_GROUP_ENCRYPT_MESSAGE = 304;
|
|
|
|
|
|
|
|
public static final int EXCEPTION_CODE_INIT_SESSION_CREATION = 400;
|
|
|
|
public static final int EXCEPTION_CODE_SESSION_INIT_OUTBOUND_SESSION = 401;
|
|
|
|
public static final int EXCEPTION_CODE_SESSION_INIT_INBOUND_SESSION = 402;
|
|
|
|
public static final int EXCEPTION_CODE_SESSION_INIT_INBOUND_SESSION_FROM = 403;
|
|
|
|
public static final int EXCEPTION_CODE_SESSION_ENCRYPT_MESSAGE = 404;
|
|
|
|
public static final int EXCEPTION_CODE_SESSION_DECRYPT_MESSAGE = 405;
|
|
|
|
public static final int EXCEPTION_CODE_SESSION_SESSION_IDENTIFIER = 406;
|
2022-02-15 22:04:10 +01:00
|
|
|
public static final int EXCEPTION_CODE_SESSION_SESSION_DESCRIBE = 407;
|
2017-01-09 10:25:18 +01:00
|
|
|
|
2017-01-09 15:29:23 +01:00
|
|
|
public static final int EXCEPTION_CODE_UTILITY_CREATION = 500;
|
|
|
|
public static final int EXCEPTION_CODE_UTILITY_VERIFY_SIGNATURE = 501;
|
2017-01-04 12:35:15 +01:00
|
|
|
|
2018-06-27 23:38:14 +02:00
|
|
|
public static final int EXCEPTION_CODE_PK_ENCRYPTION_CREATION = 600;
|
|
|
|
public static final int EXCEPTION_CODE_PK_ENCRYPTION_SET_RECIPIENT_KEY = 601;
|
|
|
|
public static final int EXCEPTION_CODE_PK_ENCRYPTION_ENCRYPT = 602;
|
|
|
|
|
|
|
|
public static final int EXCEPTION_CODE_PK_DECRYPTION_CREATION = 700;
|
|
|
|
public static final int EXCEPTION_CODE_PK_DECRYPTION_GENERATE_KEY = 701;
|
|
|
|
public static final int EXCEPTION_CODE_PK_DECRYPTION_DECRYPT = 702;
|
2018-10-18 04:29:01 +02:00
|
|
|
public static final int EXCEPTION_CODE_PK_DECRYPTION_SET_PRIVATE_KEY = 703;
|
|
|
|
public static final int EXCEPTION_CODE_PK_DECRYPTION_PRIVATE_KEY = 704;
|
2018-06-27 23:38:14 +02:00
|
|
|
|
2019-03-14 03:43:56 +01:00
|
|
|
public static final int EXCEPTION_CODE_PK_SIGNING_CREATION = 800;
|
|
|
|
public static final int EXCEPTION_CODE_PK_SIGNING_GENERATE_SEED = 801;
|
|
|
|
public static final int EXCEPTION_CODE_PK_SIGNING_INIT_WITH_SEED = 802;
|
|
|
|
public static final int EXCEPTION_CODE_PK_SIGNING_SIGN = 803;
|
|
|
|
|
2019-03-26 14:30:19 +01:00
|
|
|
public static final int EXCEPTION_CODE_SAS_CREATION = 900;
|
|
|
|
public static final int EXCEPTION_CODE_SAS_ERROR = 901;
|
|
|
|
public static final int EXCEPTION_CODE_SAS_MISSING_THEIR_PKEY = 902;
|
|
|
|
public static final int EXCEPTION_CODE_SAS_GENERATE_SHORT_CODE = 903;
|
|
|
|
|
2016-10-18 16:05:28 +02:00
|
|
|
// exception human readable messages
|
2016-10-21 19:05:20 +02:00
|
|
|
public static final String EXCEPTION_MSG_INVALID_PARAMS_DESERIALIZATION = "invalid de-serialized parameters";
|
2016-10-14 15:27:20 +02:00
|
|
|
|
2016-10-28 10:49:04 +02:00
|
|
|
/** exception code to be taken from: {@link #EXCEPTION_CODE_CREATE_OUTBOUND_GROUP_SESSION}, {@link #EXCEPTION_CODE_CREATE_INBOUND_GROUP_SESSION},
|
|
|
|
* {@link #EXCEPTION_CODE_INIT_OUTBOUND_GROUP_SESSION}, {@link #EXCEPTION_CODE_INIT_INBOUND_GROUP_SESSION}..**/
|
2016-10-14 15:27:20 +02:00
|
|
|
private final int mCode;
|
|
|
|
|
2016-10-18 16:05:28 +02:00
|
|
|
/** Human readable message description **/
|
|
|
|
private final String mMessage;
|
|
|
|
|
|
|
|
public OlmException(int aExceptionCode, String aExceptionMessage) {
|
2016-10-14 15:27:20 +02:00
|
|
|
super();
|
|
|
|
mCode = aExceptionCode;
|
2016-10-18 16:05:28 +02:00
|
|
|
mMessage = aExceptionMessage;
|
2016-10-14 15:27:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getExceptionCode() {
|
|
|
|
return mCode;
|
|
|
|
}
|
2016-10-19 15:23:19 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getMessage() {
|
|
|
|
return mMessage;
|
|
|
|
}
|
2016-10-14 15:27:20 +02:00
|
|
|
}
|