2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 21:55:10 +00:00

Remove useless catch-and-throw

This commit is contained in:
Albert Vaca
2018-08-31 21:42:35 +02:00
parent 7daea0ff78
commit 6ae878fec2

View File

@@ -72,37 +72,22 @@ public class RsaHelper {
} }
public static PublicKey getPublicKey(Context context) throws Exception { public static PublicKey getPublicKey(Context context) throws GeneralSecurityException {
try { SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context); byte[] publicKeyBytes = Base64.decode(settings.getString("publicKey", ""), 0);
byte[] publicKeyBytes = Base64.decode(settings.getString("publicKey", ""), 0); return KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKeyBytes));
return KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKeyBytes));
} catch (Exception e) {
throw e;
}
} }
public static PublicKey getPublicKey(Context context, String deviceId) throws Exception { public static PublicKey getPublicKey(Context context, String deviceId) throws GeneralSecurityException {
try { SharedPreferences settings = context.getSharedPreferences(deviceId, Context.MODE_PRIVATE);
SharedPreferences settings = context.getSharedPreferences(deviceId, Context.MODE_PRIVATE); byte[] publicKeyBytes = Base64.decode(settings.getString("publicKey", ""), 0);
byte[] publicKeyBytes = Base64.decode(settings.getString("publicKey", ""), 0); return KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKeyBytes));
return KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(publicKeyBytes));
} catch (Exception e) {
throw e;
}
} }
public static PrivateKey getPrivateKey(Context context) throws Exception { public static PrivateKey getPrivateKey(Context context) throws GeneralSecurityException {
SharedPreferences globalSettings = PreferenceManager.getDefaultSharedPreferences(context);
try { byte[] privateKeyBytes = Base64.decode(globalSettings.getString("privateKey", ""), 0);
SharedPreferences globalSettings = PreferenceManager.getDefaultSharedPreferences(context); return KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(privateKeyBytes));
byte[] privateKeyBytes = Base64.decode(globalSettings.getString("privateKey", ""), 0);
return KeyFactory.getInstance("RSA").generatePrivate(new PKCS8EncodedKeySpec(privateKeyBytes));
} catch (Exception e) {
throw e;
}
} }
public static NetworkPacket encrypt(NetworkPacket np, PublicKey publicKey) throws GeneralSecurityException, JSONException { public static NetworkPacket encrypt(NetworkPacket np, PublicKey publicKey) throws GeneralSecurityException, JSONException {