iOS: Encrypt TS Gateway passwords
This commit is contained in:
parent
935aa5e2ea
commit
c55f3d6426
@ -28,16 +28,21 @@
|
|||||||
|
|
||||||
_connection_params = [dict mutableDeepCopy];
|
_connection_params = [dict mutableDeepCopy];
|
||||||
|
|
||||||
if ([[_connection_params objectForKey:@"password"] isKindOfClass:[NSData class]])
|
[self decryptPasswordForKey:@"password"];
|
||||||
{
|
[self decryptPasswordForKey:@"tsg_password"];
|
||||||
NSString* plaintext_password = [[[EncryptionController sharedEncryptionController] decryptor] decryptString:[_connection_params objectForKey:@"password"]];
|
|
||||||
|
|
||||||
[self setValue:plaintext_password forKey:@"password"];
|
|
||||||
}
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)decryptPasswordForKey:(NSString*)key
|
||||||
|
{
|
||||||
|
if ([[_connection_params objectForKey:key] isKindOfClass:[NSData class]])
|
||||||
|
{
|
||||||
|
NSString* plaintext_password = [[[EncryptionController sharedEncryptionController] decryptor] decryptString:[_connection_params objectForKey:key]];
|
||||||
|
[self setValue:plaintext_password forKey:key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (id)initWithBaseDefaultParameters
|
- (id)initWithBaseDefaultParameters
|
||||||
{
|
{
|
||||||
return [self initWithDictionary:[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"TSXDefaultComputerBookmarkSettings"]];
|
return [self initWithDictionary:[[NSUserDefaults standardUserDefaults] dictionaryForKey:@"TSXDefaultComputerBookmarkSettings"]];
|
||||||
@ -89,19 +94,23 @@
|
|||||||
[serializable_params setObject:[_connection_params objectForKey:k] forKey:k];
|
[serializable_params setObject:[_connection_params objectForKey:k] forKey:k];
|
||||||
|
|
||||||
if ([serializable_params objectForKey:@"password"] != nil)
|
if ([serializable_params objectForKey:@"password"] != nil)
|
||||||
{
|
[self serializeDecryptedForKey:@"password" forParams:serializable_params];
|
||||||
NSData* encrypted_password = [[[EncryptionController sharedEncryptionController] encryptor] encryptString:[serializable_params objectForKey:@"password"]];
|
if ([serializable_params objectForKey:@"tsg_password"] != nil)
|
||||||
|
[self serializeDecryptedForKey:@"tsg_password" forParams:serializable_params];
|
||||||
if (encrypted_password)
|
|
||||||
[serializable_params setObject:encrypted_password forKey:@"password"];
|
|
||||||
else
|
|
||||||
[serializable_params removeObjectForKey:@"password"];
|
|
||||||
}
|
|
||||||
|
|
||||||
[coder encodeObject:serializable_params forKey:@"connectionParams"];
|
[coder encodeObject:serializable_params forKey:@"connectionParams"];
|
||||||
[serializable_params release];
|
[serializable_params release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)serializeDecryptedForKey:(NSString*)key forParams:(NSMutableDictionary*)params
|
||||||
|
{
|
||||||
|
NSData* encrypted_password = [[[EncryptionController sharedEncryptionController] encryptor] encryptString:[params objectForKey:key]];
|
||||||
|
|
||||||
|
if (encrypted_password)
|
||||||
|
[params setObject:encrypted_password forKey:key];
|
||||||
|
else
|
||||||
|
[params removeObjectForKey:key];
|
||||||
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark NSKeyValueCoding
|
#pragma mark NSKeyValueCoding
|
||||||
|
Loading…
Reference in New Issue
Block a user