mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-22 01:34:26 +00:00
Replace implementations of Base16, Base32 and Base64 with Guava
I kept the classes in the encoding package and turned them into wrappers for Guava. I also changed the functions in the Base32 class to take and return strings insteads if character arrays.
This commit is contained in:
parent
833e75ade1
commit
10ac1af6b0
23 changed files with 88 additions and 254 deletions
|
@ -1,6 +1,6 @@
|
|||
package com.beemdevelopment.aegis.vault;
|
||||
|
||||
import com.beemdevelopment.aegis.encoding.Base64Exception;
|
||||
import com.beemdevelopment.aegis.encoding.EncodingException;
|
||||
import com.beemdevelopment.aegis.otp.OtpInfoException;
|
||||
import com.beemdevelopment.aegis.util.UUIDMap;
|
||||
|
||||
|
@ -43,7 +43,7 @@ public class Vault {
|
|||
VaultEntry entry = VaultEntry.fromJson(array.getJSONObject(i));
|
||||
entries.add(entry);
|
||||
}
|
||||
} catch (Base64Exception | OtpInfoException | JSONException e) {
|
||||
} catch (EncodingException | OtpInfoException | JSONException e) {
|
||||
throw new VaultException(e);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.beemdevelopment.aegis.vault;
|
||||
|
||||
import com.beemdevelopment.aegis.encoding.Base64;
|
||||
import com.beemdevelopment.aegis.encoding.Base64Exception;
|
||||
import com.beemdevelopment.aegis.encoding.EncodingException;
|
||||
import com.beemdevelopment.aegis.otp.GoogleAuthInfo;
|
||||
import com.beemdevelopment.aegis.otp.OtpInfo;
|
||||
import com.beemdevelopment.aegis.otp.OtpInfoException;
|
||||
|
@ -60,7 +60,7 @@ public class VaultEntry extends UUIDMap.Value {
|
|||
return obj;
|
||||
}
|
||||
|
||||
public static VaultEntry fromJson(JSONObject obj) throws JSONException, OtpInfoException, Base64Exception {
|
||||
public static VaultEntry fromJson(JSONObject obj) throws JSONException, OtpInfoException, EncodingException {
|
||||
// if there is no uuid, generate a new one
|
||||
UUID uuid;
|
||||
if (!obj.has("uuid")) {
|
||||
|
|
|
@ -3,11 +3,10 @@ package com.beemdevelopment.aegis.vault;
|
|||
import com.beemdevelopment.aegis.crypto.CryptParameters;
|
||||
import com.beemdevelopment.aegis.crypto.CryptResult;
|
||||
import com.beemdevelopment.aegis.crypto.MasterKeyException;
|
||||
import com.beemdevelopment.aegis.encoding.Base64;
|
||||
import com.beemdevelopment.aegis.encoding.EncodingException;
|
||||
import com.beemdevelopment.aegis.vault.slots.SlotList;
|
||||
import com.beemdevelopment.aegis.vault.slots.SlotListException;
|
||||
import com.beemdevelopment.aegis.encoding.Base64;
|
||||
import com.beemdevelopment.aegis.encoding.Base64Exception;
|
||||
import com.beemdevelopment.aegis.encoding.HexException;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -95,7 +94,7 @@ public class VaultFile {
|
|||
byte[] bytes = Base64.decode((String) _content);
|
||||
CryptResult result = creds.decrypt(bytes, _header.getParams());
|
||||
return new JSONObject(new String(result.getData(), StandardCharsets.UTF_8));
|
||||
} catch (MasterKeyException | JSONException | Base64Exception e) {
|
||||
} catch (MasterKeyException | JSONException | EncodingException e) {
|
||||
throw new VaultFileException(e);
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +135,7 @@ public class VaultFile {
|
|||
SlotList slots = SlotList.fromJson(obj.getJSONArray("slots"));
|
||||
CryptParameters params = CryptParameters.fromJson(obj.getJSONObject("params"));
|
||||
return new Header(slots, params);
|
||||
} catch (SlotListException | JSONException | HexException e) {
|
||||
} catch (SlotListException | JSONException | EncodingException e) {
|
||||
throw new VaultFileException(e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ import com.beemdevelopment.aegis.crypto.CryptResult;
|
|||
import com.beemdevelopment.aegis.crypto.CryptoUtils;
|
||||
import com.beemdevelopment.aegis.crypto.MasterKey;
|
||||
import com.beemdevelopment.aegis.crypto.SCryptParameters;
|
||||
import com.beemdevelopment.aegis.encoding.EncodingException;
|
||||
import com.beemdevelopment.aegis.encoding.Hex;
|
||||
import com.beemdevelopment.aegis.encoding.HexException;
|
||||
import com.beemdevelopment.aegis.util.UUIDMap;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
@ -144,7 +144,7 @@ public abstract class Slot extends UUIDMap.Value {
|
|||
default:
|
||||
throw new SlotException("unrecognized slot type");
|
||||
}
|
||||
} catch (JSONException | HexException e) {
|
||||
} catch (JSONException | EncodingException e) {
|
||||
throw new SlotException(e);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue