Skip to content

Add object detection, tracking, mobile notifications, and search to any security camera.

use keychain

roryclear37cc812b5e93
diff --git a/clearcam/SceneState.m b/clearcam/SceneState.m
index 9c471d5..53bc860 100644
--- a/clearcam/SceneState.m
+++ b/clearcam/SceneState.m
@@ -1,5 +1,6 @@
#import "SceneState.h"
#import "SettingsManager.h"
+#import "SecretManager.h"
#import "AppDelegate.h"
#import <MobileCoreServices/MobileCoreServices.h> // Add this import
#import <CommonCrypto/CommonCryptor.h>
@@ -169,7 +170,7 @@
}
- (void)sendEmailWithImageAtPath:(NSString *)imagePath {
- NSString *server = @"http://192.168.1.113:8080";
+ NSString *server = @"http://192.168.1.100:8080";
NSString *endpoint = @"/";
NSString *toEmail = [[NSUserDefaults standardUserDefaults] stringForKey:@"user_email"];
if (!toEmail) return;
@@ -187,14 +188,15 @@
BOOL encryptImage = [[NSUserDefaults standardUserDefaults] boolForKey:@"encrypt_email_data_enabled"];
if (encryptImage) {
- // Retrieve the user's password from the secrets manager
- NSString *encryptionKey = [[NSUserDefaults standardUserDefaults] stringForKey:@"email_encryption_password"];
+ // Retrieve the user's password from the Keychain
+ NSString *encryptionKey = [[[SecretManager sharedManager] getAllStoredKeys] firstObject];
+
if (!encryptionKey) {
- NSLog(@"Encryption key not found. Encryption aborted.");
+ NSLog(@"Encryption key not found in Keychain. Encryption aborted.");
return;
}
- // Encrypt the image data using the user's password
+ // Encrypt the image data using the retrieved key
fileData = [self encryptData:imageData withKey:encryptionKey];
if (!fileData) {
NSLog(@"Encryption failed.");
@@ -202,6 +204,7 @@
}
}
+
NSString *boundary = [NSString stringWithFormat:@"Boundary-%@", [[NSUUID UUID] UUIDString]];
NSMutableData *bodyData = [NSMutableData data];
diff --git a/clearcam/SettingsViewController.m b/clearcam/SettingsViewController.m
index 4035859..579341b 100644
--- a/clearcam/SettingsViewController.m
+++ b/clearcam/SettingsViewController.m
@@ -1,5 +1,6 @@
#import "SettingsViewController.h"
#import "SettingsManager.h"
+#import "SecretManager.h"
#import "NumberSelectionViewController.h"
@interface SettingsViewController () <UITableViewDelegate, UITableViewDataSource>
@@ -254,14 +255,30 @@
}
- (void)savePasswordToSecretsManager:(NSString *)password {
- // Replace this with your actual secrets manager logic
- [[NSUserDefaults standardUserDefaults] setObject:password forKey:@"email_encryption_password"];
- [[NSUserDefaults standardUserDefaults] synchronize];
+ if (!password) {
+ NSLog(@"Error: Password cannot be nil.");
+ return;
+ }
+
+ NSError *error = nil;
+ BOOL success = [[SecretManager sharedManager] saveKey:password error:&error];
+
+ if (!success) {
+ NSLog(@"Failed to save password to Keychain: %@", error.localizedDescription);
+ } else {
+ NSLog(@"Password successfully saved to Keychain.");
+ }
}
- (NSString *)retrievePasswordFromSecretsManager {
- // Replace this with your actual secrets manager logic
- return [[NSUserDefaults standardUserDefaults] stringForKey:@"email_encryption_password"];
+ NSArray<NSString *> *storedKeys = [[SecretManager sharedManager] getAllStoredKeys];
+
+ if (storedKeys.count > 0) {
+ return storedKeys.firstObject; // Assuming only one password is stored
+ }
+
+ NSLog(@"No password found in Keychain.");
+ return nil;
}
- (void)showInvalidPasswordAlert {