site.name -> siteName, add identicon marshalling to iOS, missing resultState
This commit is contained in:
parent
2637e9ba99
commit
a37b095a66
@ -641,10 +641,10 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
||||
|
||||
// Find an existing site to update.
|
||||
NSFetchRequest *siteFetchRequest = [NSFetchRequest fetchRequestWithEntityName:NSStringFromClass( [MPSiteEntity class] )];
|
||||
siteFetchRequest.predicate = [NSPredicate predicateWithFormat:@"name == %@ AND user == %@", @(importSite->name), user];
|
||||
siteFetchRequest.predicate = [NSPredicate predicateWithFormat:@"name == %@ AND user == %@", @(importSite->siteName), user];
|
||||
NSArray *existingSites = [context executeFetchRequest:siteFetchRequest error:&error];
|
||||
if (!existingSites)
|
||||
return MPError( error, @"Lookup of existing sites failed for site: %@, user: %@", @(importSite->name), user.userID );
|
||||
return MPError( error, @"Lookup of existing sites failed for site: %@, user: %@", @(importSite->siteName), user.userID );
|
||||
if ([existingSites count])
|
||||
// Update existing site.
|
||||
for (MPSiteEntity *site in existingSites) {
|
||||
@ -656,7 +656,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
||||
id<MPAlgorithm> algorithm = MPAlgorithmForVersion( importSite->algorithm );
|
||||
Class entityType = [algorithm classOfType:importSite->type];
|
||||
if (!entityType)
|
||||
return MPMakeError( @"Invalid site type in import file: %@ has type %lu", @(importSite->name), (long)importSite->type );
|
||||
return MPMakeError( @"Invalid site type in import file: %@ has type %lu", @(importSite->siteName), (long)importSite->type );
|
||||
|
||||
MPSiteEntity *site = (MPSiteEntity *)[entityType insertNewObjectInContext:context];
|
||||
site.user = user;
|
||||
@ -683,7 +683,7 @@ PearlAssociatedObjectProperty( NSNumber*, StoreCorrupted, storeCorrupted );
|
||||
- (void)importSite:(const MPMarshalledSite *)importSite protectedByKey:(MPKey *)importKey intoSite:(MPSiteEntity *)site
|
||||
usingKey:(MPKey *)userKey {
|
||||
|
||||
site.name = @(importSite->name);
|
||||
site.name = @(importSite->siteName);
|
||||
if (importSite->content)
|
||||
[site.algorithm importPassword:@(importSite->content) protectedByKey:importKey intoSite:site usingKey:userKey];
|
||||
site.type = importSite->type;
|
||||
|
@ -240,7 +240,7 @@ int main(const int argc, char *const argv[]) {
|
||||
dbg( "sitesPath : %s", operation.sitesPath );
|
||||
}
|
||||
if (operation.site) {
|
||||
dbg( "siteName : %s", operation.site->name );
|
||||
dbg( "siteName : %s", operation.site->siteName );
|
||||
dbg( "siteCounter : %u", operation.siteCounter );
|
||||
dbg( "resultType : %s (%u)", mpw_type_short_name( operation.resultType ), operation.resultType );
|
||||
dbg( "resultParam : %s", operation.resultParam );
|
||||
@ -552,7 +552,7 @@ void cli_site(Arguments *args, Operation *operation) {
|
||||
|
||||
// Load the site object from mpsites.
|
||||
for (size_t s = 0; !operation->site && s < operation->user->sites_count; ++s)
|
||||
if (strcmp( operation->siteName, (&operation->user->sites[s])->name ) == 0)
|
||||
if (strcmp( operation->siteName, (&operation->user->sites[s])->siteName ) == 0)
|
||||
operation->site = &operation->user->sites[s];
|
||||
|
||||
// If no site from mpsites, create a new one.
|
||||
@ -715,7 +715,7 @@ void cli_mpw(Arguments *args, Operation *operation) {
|
||||
|
||||
if (mpw_verbosity >= inf_level)
|
||||
fprintf( stderr, "%s's %s for %s:\n[ %s ]: ",
|
||||
operation->user->fullName, operation->purposeResult, operation->site->name, operation->identicon );
|
||||
operation->user->fullName, operation->purposeResult, operation->site->siteName, operation->identicon );
|
||||
|
||||
// Determine master key.
|
||||
MPMasterKey masterKey = operation->user->masterKeyProvider( operation->site->algorithm, operation->user->fullName );
|
||||
@ -728,7 +728,7 @@ void cli_mpw(Arguments *args, Operation *operation) {
|
||||
// Update state from resultParam if stateful.
|
||||
if (operation->resultParam && operation->resultType & MPResultTypeClassStateful) {
|
||||
mpw_free_string( &operation->resultState );
|
||||
if (!(operation->resultState = mpw_site_state( masterKey, operation->site->name, operation->siteCounter,
|
||||
if (!(operation->resultState = mpw_site_state( masterKey, operation->site->siteName, operation->siteCounter,
|
||||
operation->keyPurpose, operation->keyContext, operation->resultType, operation->resultParam,
|
||||
operation->site->algorithm ))) {
|
||||
ftl( "Couldn't encrypt site result." );
|
||||
@ -766,7 +766,7 @@ void cli_mpw(Arguments *args, Operation *operation) {
|
||||
operation->resultParam = mpw_strdup( operation->resultState );
|
||||
|
||||
// Generate result.
|
||||
const char *result = mpw_site_result( masterKey, operation->site->name, operation->siteCounter,
|
||||
const char *result = mpw_site_result( masterKey, operation->site->siteName, operation->siteCounter,
|
||||
operation->keyPurpose, operation->keyContext, operation->resultType, operation->resultParam, operation->site->algorithm );
|
||||
mpw_free( &masterKey, MPMasterKeySize );
|
||||
if (!result) {
|
||||
|
@ -58,7 +58,7 @@ MPMarshalledSite *mpw_marshal_site(
|
||||
|
||||
MPMarshalledSite *site = &user->sites[user->sites_count - 1];
|
||||
*site = (MPMarshalledSite){
|
||||
.name = mpw_strdup( siteName ),
|
||||
.siteName = mpw_strdup( siteName ),
|
||||
.algorithm = algorithmVersion,
|
||||
.counter = siteCounter,
|
||||
|
||||
@ -119,7 +119,7 @@ bool mpw_marshal_free(
|
||||
|
||||
for (size_t s = 0; s < (*user)->sites_count; ++s) {
|
||||
MPMarshalledSite *site = &(*user)->sites[s];
|
||||
success &= mpw_free_strings( &site->name, &site->resultState, &site->loginState, &site->url, NULL );
|
||||
success &= mpw_free_strings( &site->siteName, &site->resultState, &site->loginState, &site->url, NULL );
|
||||
|
||||
for (size_t q = 0; q < site->questions_count; ++q) {
|
||||
MPMarshalledQuestion *question = &site->questions[q];
|
||||
@ -177,7 +177,7 @@ static bool mpw_marshal_write_flat(
|
||||
// Sites.
|
||||
for (size_t s = 0; s < user->sites_count; ++s) {
|
||||
MPMarshalledSite *site = &user->sites[s];
|
||||
if (!site->name || !strlen( site->name ))
|
||||
if (!site->siteName || !strlen( site->siteName ))
|
||||
continue;
|
||||
|
||||
const char *resultState = NULL, *loginState = NULL;
|
||||
@ -189,9 +189,9 @@ static bool mpw_marshal_write_flat(
|
||||
return false;
|
||||
}
|
||||
|
||||
resultState = mpw_site_result( masterKey, site->name, site->counter,
|
||||
resultState = mpw_site_result( masterKey, site->siteName, site->counter,
|
||||
MPKeyPurposeAuthentication, NULL, site->resultType, site->resultState, site->algorithm );
|
||||
loginState = mpw_site_result( masterKey, site->name, MPCounterValueInitial,
|
||||
loginState = mpw_site_result( masterKey, site->siteName, MPCounterValueInitial,
|
||||
MPKeyPurposeIdentification, NULL, site->loginType, site->loginState, site->algorithm );
|
||||
}
|
||||
else {
|
||||
@ -205,7 +205,7 @@ static bool mpw_marshal_write_flat(
|
||||
if (strftime( dateString, sizeof( dateString ), "%FT%TZ", gmtime( &site->lastUsed ) ))
|
||||
mpw_string_pushf( out, "%s %8ld %lu:%lu:%lu %25s\t%25s\t%s\n",
|
||||
dateString, (long)site->uses, (long)site->resultType, (long)site->algorithm, (long)site->counter,
|
||||
loginState? loginState: "", site->name, resultState? resultState: "" );
|
||||
loginState? loginState: "", site->siteName, resultState? resultState: "" );
|
||||
mpw_free_strings( &resultState, &loginState, NULL );
|
||||
}
|
||||
mpw_free( &masterKey, MPMasterKeySize );
|
||||
@ -668,10 +668,10 @@ static MPMarshalledUser *mpw_marshal_read_flat(
|
||||
}
|
||||
|
||||
if (siteResultState && strlen( siteResultState ))
|
||||
site->resultState = mpw_site_state( masterKey, site->name, site->counter,
|
||||
site->resultState = mpw_site_state( masterKey, site->siteName, site->counter,
|
||||
MPKeyPurposeAuthentication, NULL, site->resultType, siteResultState, site->algorithm );
|
||||
if (siteLoginState && strlen( siteLoginState ))
|
||||
site->loginState = mpw_site_state( masterKey, site->name, MPCounterValueInitial,
|
||||
site->loginState = mpw_site_state( masterKey, site->siteName, MPCounterValueInitial,
|
||||
MPKeyPurposeIdentification, NULL, site->loginType, siteLoginState, site->algorithm );
|
||||
}
|
||||
else {
|
||||
|
@ -73,7 +73,7 @@ typedef struct MPMarshalledQuestion {
|
||||
} MPMarshalledQuestion;
|
||||
|
||||
typedef struct MPMarshalledSite {
|
||||
const char *name;
|
||||
const char *siteName;
|
||||
MPAlgorithmVersion algorithm;
|
||||
MPCounterValue counter;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user