Creates a new secure store (a vault).
+ (SUPDataVault*)createVault:(NSString*)name withPassword:(NSString*)password withSalt:(NSString*)salt;
Returns the newly created instance of the DataVault with the provided ID. The returned DataVault is in the unlocked state with default configuration values. To change the default configuration values, you can immediately call the "set" methods for the values you want to change.
If a vault already exists with the same name, a SUPDataVaultException is thrown with the reason kDataVaultExceptionReasonAlreadyExists.
@try { if(![SUPDataVault vaultExists:@"myVault"]) { oVault = [SUPDataVault createVault:@"myVault" withPassword:@"goodPassword" withSalt:@"goodSalt"]; } } @catch ( NSException *e ) { NSLog(@"SUPDataVaultException: %@",[e description]); }
@try { if ( ![MessagingClientLib isMessagingDBExist] ) { [SUPDataVault deleteVault:kMessagingDataVaultID]; } } @catch (SUPDataVaultException *exception) { // Ignore this exception // If application is installed for the first time on the device, DataVault will not exist // In this case deleteVault throws an exception which can be ignored } SUPDataVault* dataVault = nil; @try { dataVault = [SUPDataVault getVault:kMessagingDataVaultID]; } @catch (SUPDataVaultException *exception) { if ( [exception reason] == kDataVaultExceptionReasonDoesNotExist ) { // Create a vault with a hard coded PIN and force the // user to create a PIN if the security level warrants it // Otherwise just use the hard coded PIN @try { dataVault = [SUPDataVault createVault:kMessagingDataVaultID withPassword:kDVStandardPassword withSalt:kDVStandardSalt]; } @catch (NSException * e) { // getVault and createVault failed. This should not happen return -1; //UnexpectedError; } } } if ( [dataVault isLocked] ) { // Try the default PIN @try { [dataVault unlock:kDVStandardPassword withSalt:kDVStandardSalt]; } @catch (SUPDataVaultException *exception) { if ( [exception reason] == kDataVaultExceptionReasonInvalidPassword ) { return -2; //DataVault is Locked; } else { // Unable to unlock the DataVault with standard password and reason is not invalid password. // This means it failed to unlock for some other reason which shoule not happen return -1; //UnexpectedError; } } } return 0; // Success