Skip to content
This repository was archived by the owner on Jan 21, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions MASFoundation/Classes/_private_/models/MASDevice+MASPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,13 @@
*/
+ (NSString *)deviceNameBase64Encoded;


/**
* Retrieves the device vendor identifier that is uniquely generated for the
* specific device the framework is running upon.
*
* @return Returns the unique NSString device vendor identifier.
*/
+ (NSString *)deviceVendorId;

@end
18 changes: 17 additions & 1 deletion MASFoundation/Classes/_private_/models/MASDevice+MASPrivate.m
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ - (void)saveWithUpdatedInfo:(NSDictionary *)info
[accessService setAccessValueNumber:[NSNumber numberWithDouble:[expirationDate timeIntervalSince1970]] withAccessValueType:MASAccessValueTypeSignedPublicCertificateExpirationDate];
}

//
// Device Vendor Id
//
NSString *deviceVendorId = [MASDevice deviceVendorId];
if (deviceVendorId)
{
[accessService setAccessValueString:deviceVendorId withAccessValueType:MASAccessValueTypeDeviceVendorId];
}

//
// Reload MASAccess object after storing id-token and type
//
Expand Down Expand Up @@ -183,7 +192,7 @@ - (BOOL)isClientCertificateExpired

+ (NSString *)deviceIdBase64Encoded
{
NSString *deviceId = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
NSString *deviceId = [MASDevice deviceVendorId];

//
// If the sso is disabled, generate unique device id to differentiate the application's registration record from others.
Expand Down Expand Up @@ -215,4 +224,11 @@ + (NSString *)deviceNameBase64Encoded;
return [deviceNameData base64EncodedStringWithOptions:0];
}


+ (NSString *)deviceVendorId
{
return [[[UIDevice currentDevice] identifierForVendor] UUIDString];
}


@end
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ typedef NS_ENUM(NSInteger, MASAccessValueType)
MASAccessValueTypeTrustedServerCertificate,
MASAccessValueTypeCurrentAuthCredentialsGrantType,
MASAccessValueTypeMASUserObjectData,
MASAccessValueTypeDeviceVendorId,
};


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,9 @@ - (NSString *)getStorageKeyWithAccessValueType:(MASAccessValueType)type
case MASAccessValueTypeMASUserObjectData:
storageKey = kMASAccessSharedStorageKey;
break;
case MASAccessValueTypeDeviceVendorId:
storageKey = kMASAccessSharedStorageKey;
break;
default:
//
// MASAccessValueTypeUknonw
Expand Down Expand Up @@ -857,24 +860,33 @@ - (NSString *)convertAccessTypeToString:(MASAccessValueType)type
case MASAccessValueTypeSignedPublicCertificateExpirationDate:
accessTypeToString = [NSString stringWithFormat:@"%@.%@", _gatewayIdentifier, @"kMASAccessValueTypeSignedPublicCertificateExpirationDate"];
break;
//AuthenticatedTimestamp
case MASAccessValueTypeAuthenticatedTimestamp:
accessTypeToString = [NSString stringWithFormat:@"%@.%@", _gatewayIdentifier, @"kMASAccessValueTypeAuthenticatedTimestamp"];
break;
//IsDeviceLocked:
case MASAccessValueTypeIsDeviceLocked:
accessTypeToString = [NSString stringWithFormat:@"%@.%@", _gatewayIdentifier, @"kMASAccessValueTypeIsDeviceLocked"];
break;
//CurrentAuthCredentialsGrantType
case MASAccessValueTypeCurrentAuthCredentialsGrantType:
accessTypeToString = [NSString stringWithFormat:@"%@.%@", _gatewayIdentifier, @"kMASAccessValueTypeCurrentAuthCredentialsGrantType"];
break;
//MASUserObjectData
case MASAccessValueTypeMASUserObjectData:
accessTypeToString = [NSString stringWithFormat:@"%@.%@", _gatewayHostName, @"kMASAccessValueTypeMASUserObjectData"];
break;
//DeviceVendorId
case MASAccessValueTypeDeviceVendorId:
accessTypeToString = [NSString stringWithFormat:@"%@.%@", _gatewayHostName, @"kMASKeyChainDeviceVendorId"];
break;
default:
//
// MASAccessValueTypeUknonw
//
break;
}

if (![self isAccessGroupAccessible])
{
accessTypeToString = [NSString stringWithFormat:@"_%@", accessTypeToString];
Expand Down
20 changes: 15 additions & 5 deletions MASFoundation/Classes/models/MASDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,26 @@ + (void)setProximityLoginDelegate:(id<MASProximityLoginDelegate>)delegate

- (BOOL)isRegistered
{
_isRegistered = NO;

//
// Obtain key chain items to determine registration status
//
MASAccessService *accessService = [MASAccessService sharedService];

NSString *magIdentifier = [accessService getAccessValueStringWithType:MASAccessValueTypeMAGIdentifier];
NSData *certificateData = [accessService getAccessValueCertificateWithType:MASAccessValueTypeSignedPublicCertificate];

_isRegistered = (magIdentifier && certificateData);
NSString *vendorIdFromKeychain = [accessService getAccessValueStringWithType:MASAccessValueTypeDeviceVendorId];
NSString *vendorIdCurrent = [MASDevice deviceVendorId];

//
// Check if the vendorId in Keychain macth with current vendorId
//
if([vendorIdCurrent isEqualToString:vendorIdFromKeychain])
{
NSString *magIdentifier = [accessService getAccessValueStringWithType:MASAccessValueTypeMAGIdentifier];
NSData *certificateData = [accessService getAccessValueCertificateWithType:MASAccessValueTypeSignedPublicCertificate];

_isRegistered = (magIdentifier && certificateData);
}

return _isRegistered;
}
Expand Down Expand Up @@ -122,7 +133,6 @@ - (void)resetLocally
}



# pragma mark - Lifecycle

- (id)init
Expand Down