diff --git a/CryptoLib/CryptoLib/Ldap/Addressee.h b/CryptoLib/CryptoLib/Ldap/Addressee.h index e86c93235..a352a22e7 100644 --- a/CryptoLib/CryptoLib/Ldap/Addressee.h +++ b/CryptoLib/CryptoLib/Ldap/Addressee.h @@ -26,9 +26,7 @@ @property (nonatomic, strong) NSString *givenName; @property (nonatomic, strong) NSString *surname; @property (nonatomic, strong) NSString *identifier; -@property (nonatomic, strong) NSString *type; @property (nonatomic, strong) NSData *cert; @property (nonatomic, strong) NSDate *validTo; -@property (nonatomic, strong) NSArray *policyIdentifiers; @end diff --git a/MoppApp/MoppApp/AddresseeActions.swift b/MoppApp/MoppApp/AddresseeActions.swift index dcb4f12d7..bdfd31901 100644 --- a/MoppApp/MoppApp/AddresseeActions.swift +++ b/MoppApp/MoppApp/AddresseeActions.swift @@ -38,8 +38,8 @@ extension AddresseeActions { } func determineInfo(addressee: Addressee) -> String { - let policyIdentifiers = MoppLibManager.certificatePolicyIdentifiers(addressee.cert) - let addresseeType = displayAddresseeType(policyIdentifiers as? [String] ?? []) + let policyIdentifiers = MoppLibManager.certificatePolicyIdentifiers(addressee.cert) as! [String] + let addresseeType = displayAddresseeType(policyIdentifiers) let validTo = "\(L(LocKey.cryptoValidTo)) \(MoppDateFormatter.shared.ddMMYYYY(toString: addressee.validTo))" return "\(addresseeType) (\(validTo))" } diff --git a/MoppApp/MoppApp/AddresseeViewController.swift b/MoppApp/MoppApp/AddresseeViewController.swift index 3c9122d9a..add730800 100644 --- a/MoppApp/MoppApp/AddresseeViewController.swift +++ b/MoppApp/MoppApp/AddresseeViewController.swift @@ -414,7 +414,7 @@ extension AddresseeViewController : ContainerFoundAddresseeCellDelegate { if !selectedAddressees.contains(where: {( ($0.givenName != nil && $0.givenName == addressee.givenName && $0.surname != nil && $0.surname == addressee.surname) || - $0.identifier == addressee.identifier) && $0.type == addressee.type && $0.validTo == addressee.validTo + $0.identifier == addressee.identifier) && $0.cert == addressee.cert && $0.validTo == addressee.validTo }) { selectedAddressees.insert(addressee, at: 0) } diff --git a/MoppLib/MoppLib/MoppLibCertificate.mm b/MoppLib/MoppLib/MoppLibCertificate.mm index bdeffe485..25287ae0c 100644 --- a/MoppLib/MoppLib/MoppLibCertificate.mm +++ b/MoppLib/MoppLib/MoppLibCertificate.mm @@ -49,20 +49,22 @@ + (MoppLibCertificateOrganization)certificateOrganization:(const digidoc::X509Ce for (const std::string &policy: cert.certificatePolicies()) { [policies addObject:[NSString stringWithUTF8String:policy.c_str()]]; } - EIDType eidType = [MoppLibManager eidTypeFromCertificatePolicies:policies]; - switch (eidType) { - case EIDTypeUnknown: - case EIDTypeESeal: - return Unknown; - case EIDTypeMobileID: - return MobileID; - case EIDTypeSmartID: - return SmartID; - case EIDTypeDigiID: - return DigiID; - case EIDTypeIDCard: + for (NSString *policyID in policies) { + if ([policyID hasPrefix:@"1.3.6.1.4.1.10015.1.1"] + || [policyID hasPrefix:@"1.3.6.1.4.1.51361.1.1.1"]) return IDCard; + else if ([policyID hasPrefix:@"1.3.6.1.4.1.10015.1.2"] + || [policyID hasPrefix:@"1.3.6.1.4.1.51361.1.1"] + || [policyID hasPrefix:@"1.3.6.1.4.1.51455.1.1"]) + return DigiID; + else if ([policyID hasPrefix:@"1.3.6.1.4.1.10015.1.3"] + || [policyID hasPrefix:@"1.3.6.1.4.1.10015.11.1"]) + return MobileID; + else if ([policyID hasPrefix:@"1.3.6.1.4.1.10015.7.3"] + || [policyID hasPrefix:@"1.3.6.1.4.1.10015.7.1"] + || [policyID hasPrefix:@"1.3.6.1.4.1.10015.2.1"]) + return ESeal; } return Unknown; } diff --git a/MoppLib/MoppLib/PublicInterface/MoppLibCerificatetData.h b/MoppLib/MoppLib/PublicInterface/MoppLibCerificatetData.h index 87bb6b704..355ddaf1a 100644 --- a/MoppLib/MoppLib/PublicInterface/MoppLibCerificatetData.h +++ b/MoppLib/MoppLib/PublicInterface/MoppLibCerificatetData.h @@ -31,6 +31,7 @@ typedef NS_ENUM(int, MoppLibCertificateOrganization) { SmartID, DigiID, EResident, + ESeal, Unknown }; diff --git a/MoppLib/MoppLib/PublicInterface/MoppLibCryptoActions.m b/MoppLib/MoppLib/PublicInterface/MoppLibCryptoActions.m index 51459de98..a022d408f 100644 --- a/MoppLib/MoppLib/PublicInterface/MoppLibCryptoActions.m +++ b/MoppLib/MoppLib/PublicInterface/MoppLibCryptoActions.m @@ -62,9 +62,7 @@ - (void)parseCdocInfo:(NSString *)fullPath success:(CdocContainerBlock)success f } for (Addressee* addressee in response.addressees) { MoppLibCerificatetData *certData = [MoppLibCerificatetData new]; - addressee.policyIdentifiers = [MoppLibDigidocManager certificatePolicyIdentifiers:addressee.cert]; [MoppLibCertificate certData:certData updateWithDerEncoding:addressee.cert]; - addressee.type = [self formatTypeToString :certData.organization]; addressee.validTo = certData.expiryDate; } } @@ -77,23 +75,6 @@ - (void)parseCdocInfo:(NSString *)fullPath success:(CdocContainerBlock)success f }); } -- (NSString*)formatTypeToString:(MoppLibCertificateOrganization)formatType { - NSString *result = nil; - switch(formatType) { - case DigiID: - result = @"DIGI-ID"; - break; - case IDCard: - result = @"ID-CARD"; - break; - default: - result = @"E-SEAL"; - break; - } - - return result; -} - - (void)decryptData:(NSString *)fullPath withPin1:(NSString*)pin1 success:(DecryptedDataBlock)success failure:(FailureBlock)failure { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSError *error; @@ -147,26 +128,6 @@ - (void)encryptData:(NSString *)fullPath withDataFiles:(NSArray*)dataFiles withA }); } -- (MoppLibCertificateOrganization)parseEIDType:(NSArray*)certPolicies { - - EIDType eidType = [MoppLibManager eidTypeFromCertificatePolicies:certPolicies]; - - switch (eidType) { - case EIDTypeUnknown: - case EIDTypeESeal: - return Unknown; - case EIDTypeMobileID: - return MobileID; - case EIDTypeSmartID: - return SmartID; - case EIDTypeDigiID: - return DigiID; - case EIDTypeIDCard: - return IDCard; - } - return Unknown; -} - - (void)searchLdapData:(NSString *)identifier success:(LdapBlock)success failure:(FailureBlock)failure configuration:(MoppLdapConfiguration *) moppLdapConfiguration { Reachability *reachability = [Reachability reachabilityForInternetConnection]; @@ -203,8 +164,6 @@ - (void)searchLdapData:(NSString *)identifier success:(LdapBlock)success failure MoppLibCertificateInfo *certInfo = [MoppLibCertificateInfo alloc]; NSArray *certPolicies = [certInfo certificatePolicies:(certData)]; NSArray *certKeyUsages = [certInfo keyUsages:(certData)]; - - addressee.policyIdentifiers = certPolicies; if (key.cn != NULL) { NSArray *cn = [key.cn componentsSeparatedByString:@","]; @@ -214,14 +173,9 @@ - (void)searchLdapData:(NSString *)identifier success:(LdapBlock)success failure addressee.identifier = cn[2]; } else { addressee.identifier = cn[0]; - addressee.type = @"E-SEAL"; } } - if (addressee.type == nil) { - addressee.type = [self formatTypeToString:[self parseEIDType:certPolicies]]; - } - if (([certInfo hasKeyEnciphermentUsage:(certKeyUsages)] || [certInfo hasKeyAgreementUsage:(certKeyUsages)]) && ![certInfo isServerAuthKeyPurpose:(certData)] && (![certInfo isESealType:(certPolicies)] || ![certInfo isTlsClientAuthKeyPurpose:(certData)]) && diff --git a/MoppLib/MoppLib/PublicInterface/MoppLibManager.h b/MoppLib/MoppLib/PublicInterface/MoppLibManager.h index ea602c631..93df11726 100644 --- a/MoppLib/MoppLib/PublicInterface/MoppLibManager.h +++ b/MoppLib/MoppLib/PublicInterface/MoppLibManager.h @@ -28,15 +28,6 @@ #import "MoppLibRoleAddressData.h" #import "MoppLibProxyConfiguration.h" -typedef NS_ENUM(NSUInteger, EIDType) { - EIDTypeUnknown, - EIDTypeMobileID, - EIDTypeSmartID, - EIDTypeDigiID, - EIDTypeIDCard, - EIDTypeESeal -}; - @interface MoppLibManager : NSObject + (MoppLibManager *)sharedInstance; @@ -58,8 +49,6 @@ typedef NS_ENUM(NSUInteger, EIDType) { - (NSString *)appVersion; - (NSString *)iOSVersion; - (NSString *)userAgent; -+ (EIDType)eidTypeFromCertificate:(NSData*)certData; -+ (EIDType)eidTypeFromCertificatePolicies:(NSArray*)certificatePolicies; + (NSArray *)certificatePolicyIdentifiers:(NSData *)certData; + (NSString *)sanitize:(NSString *)text; diff --git a/MoppLib/MoppLib/PublicInterface/MoppLibManager.m b/MoppLib/MoppLib/PublicInterface/MoppLibManager.m index a8976e138..95157cc46 100644 --- a/MoppLib/MoppLib/PublicInterface/MoppLibManager.m +++ b/MoppLib/MoppLib/PublicInterface/MoppLibManager.m @@ -73,40 +73,6 @@ - (NSString *)userAgent { return [[MoppLibDigidocManager sharedInstance] userAgent]; } -+ (EIDType)eidTypeFromCertificate:(NSData*)certData { - NSArray *policyIdentifiers = [MoppLibDigidocManager certificatePolicyIdentifiers:certData]; - if ([policyIdentifiers count] == 0) { - return EIDTypeUnknown; - } - - return [self eidTypeFromCertificatePolicies:policyIdentifiers]; -} - -+ (EIDType)eidTypeFromCertificatePolicies:(NSArray*)policyIdentifiers { - if ([policyIdentifiers count] == 0) { - return EIDTypeUnknown; - } - - for (NSString *policyID in policyIdentifiers) { - if ([policyID hasPrefix:@"1.3.6.1.4.1.10015.1.1"] - || [policyID hasPrefix:@"1.3.6.1.4.1.51361.1.1.1"]) - return EIDTypeIDCard; - else if ([policyID hasPrefix:@"1.3.6.1.4.1.10015.1.2"] - || [policyID hasPrefix:@"1.3.6.1.4.1.51361.1.1"] - || [policyID hasPrefix:@"1.3.6.1.4.1.51455.1.1"]) - return EIDTypeDigiID; - else if ([policyID hasPrefix:@"1.3.6.1.4.1.10015.1.3"] - || [policyID hasPrefix:@"1.3.6.1.4.1.10015.11.1"]) - return EIDTypeMobileID; - else if ([policyID hasPrefix:@"1.3.6.1.4.1.10015.7.3"] - || [policyID hasPrefix:@"1.3.6.1.4.1.10015.7.1"] - || [policyID hasPrefix:@"1.3.6.1.4.1.10015.2.1"]) - return EIDTypeESeal; - } - - return EIDTypeUnknown; -} - + (NSArray *)certificatePolicyIdentifiers:(NSData *)certData { return [MoppLibDigidocManager certificatePolicyIdentifiers:certData]; }