From b0f656e83e31dbf2d3e645566c64afe7a940e90d Mon Sep 17 00:00:00 2001 From: Tejas Ardeshna Date: Fri, 3 Nov 2017 21:14:54 +0530 Subject: [PATCH] init --- .../project.pbxproj | 363 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../TJBioAuthentication/AppDelegate.swift | 46 +++ .../AppIcon.appiconset/Contents.json | 93 +++++ .../Base.lproj/LaunchScreen.storyboard | 25 ++ .../Base.lproj/Main.storyboard | 63 +++ .../BioAuth/TJAuthErrors.swift | 93 +++++ .../BioAuth/TJBioAuthenticator.swift | 131 +++++++ .../BioAuth/TJDefaultMessages.swift | 35 ++ .../Extensions/alertHelper.swift | 21 + .../Extensions/keyBoardHelper.swift | 27 ++ .../TJBioAuthentication/Info.plist | 45 +++ .../TJBioAuthentication/ViewController.swift | 64 +++ 13 files changed, 1013 insertions(+) create mode 100644 TJBioAuthentication/TJBioAuthentication.xcodeproj/project.pbxproj create mode 100644 TJBioAuthentication/TJBioAuthentication.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 TJBioAuthentication/TJBioAuthentication/AppDelegate.swift create mode 100644 TJBioAuthentication/TJBioAuthentication/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 TJBioAuthentication/TJBioAuthentication/Base.lproj/LaunchScreen.storyboard create mode 100644 TJBioAuthentication/TJBioAuthentication/Base.lproj/Main.storyboard create mode 100755 TJBioAuthentication/TJBioAuthentication/BioAuth/TJAuthErrors.swift create mode 100755 TJBioAuthentication/TJBioAuthentication/BioAuth/TJBioAuthenticator.swift create mode 100644 TJBioAuthentication/TJBioAuthentication/BioAuth/TJDefaultMessages.swift create mode 100644 TJBioAuthentication/TJBioAuthentication/Extensions/alertHelper.swift create mode 100644 TJBioAuthentication/TJBioAuthentication/Extensions/keyBoardHelper.swift create mode 100644 TJBioAuthentication/TJBioAuthentication/Info.plist create mode 100644 TJBioAuthentication/TJBioAuthentication/ViewController.swift diff --git a/TJBioAuthentication/TJBioAuthentication.xcodeproj/project.pbxproj b/TJBioAuthentication/TJBioAuthentication.xcodeproj/project.pbxproj new file mode 100644 index 0000000..026ce2f --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication.xcodeproj/project.pbxproj @@ -0,0 +1,363 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + B854ECEA1FACC5FD006225B0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B854ECE91FACC5FD006225B0 /* AppDelegate.swift */; }; + B854ECEC1FACC5FD006225B0 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B854ECEB1FACC5FD006225B0 /* ViewController.swift */; }; + B854ECEF1FACC5FD006225B0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B854ECED1FACC5FD006225B0 /* Main.storyboard */; }; + B854ECF11FACC5FD006225B0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B854ECF01FACC5FD006225B0 /* Assets.xcassets */; }; + B854ECF41FACC5FD006225B0 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B854ECF21FACC5FD006225B0 /* LaunchScreen.storyboard */; }; + B854ED031FACC633006225B0 /* alertHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B854ECFC1FACC633006225B0 /* alertHelper.swift */; }; + B854ED041FACC633006225B0 /* keyBoardHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = B854ECFD1FACC633006225B0 /* keyBoardHelper.swift */; }; + B854ED0B1FACC65C006225B0 /* TJAuthErrors.swift in Sources */ = {isa = PBXBuildFile; fileRef = B854ED081FACC65C006225B0 /* TJAuthErrors.swift */; }; + B854ED0C1FACC65C006225B0 /* TJBioAuthenticator.swift in Sources */ = {isa = PBXBuildFile; fileRef = B854ED091FACC65C006225B0 /* TJBioAuthenticator.swift */; }; + B854ED0D1FACC65C006225B0 /* TJDefaultMessages.swift in Sources */ = {isa = PBXBuildFile; fileRef = B854ED0A1FACC65C006225B0 /* TJDefaultMessages.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + B854ECE61FACC5FD006225B0 /* TJBioAuthentication.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TJBioAuthentication.app; sourceTree = BUILT_PRODUCTS_DIR; }; + B854ECE91FACC5FD006225B0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + B854ECEB1FACC5FD006225B0 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + B854ECEE1FACC5FD006225B0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + B854ECF01FACC5FD006225B0 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + B854ECF31FACC5FD006225B0 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + B854ECF51FACC5FD006225B0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B854ECFC1FACC633006225B0 /* alertHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = alertHelper.swift; sourceTree = ""; }; + B854ECFD1FACC633006225B0 /* keyBoardHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = keyBoardHelper.swift; sourceTree = ""; }; + B854ED081FACC65C006225B0 /* TJAuthErrors.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TJAuthErrors.swift; sourceTree = ""; }; + B854ED091FACC65C006225B0 /* TJBioAuthenticator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TJBioAuthenticator.swift; sourceTree = ""; }; + B854ED0A1FACC65C006225B0 /* TJDefaultMessages.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TJDefaultMessages.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + B854ECE31FACC5FD006225B0 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + B854ECDD1FACC5FD006225B0 = { + isa = PBXGroup; + children = ( + B854ECE81FACC5FD006225B0 /* TJBioAuthentication */, + B854ECE71FACC5FD006225B0 /* Products */, + ); + sourceTree = ""; + }; + B854ECE71FACC5FD006225B0 /* Products */ = { + isa = PBXGroup; + children = ( + B854ECE61FACC5FD006225B0 /* TJBioAuthentication.app */, + ); + name = Products; + sourceTree = ""; + }; + B854ECE81FACC5FD006225B0 /* TJBioAuthentication */ = { + isa = PBXGroup; + children = ( + B854ED071FACC65C006225B0 /* BioAuth */, + B854ECFB1FACC633006225B0 /* Extensions */, + B854ECE91FACC5FD006225B0 /* AppDelegate.swift */, + B854ECEB1FACC5FD006225B0 /* ViewController.swift */, + B854ECED1FACC5FD006225B0 /* Main.storyboard */, + B854ECF01FACC5FD006225B0 /* Assets.xcassets */, + B854ECF21FACC5FD006225B0 /* LaunchScreen.storyboard */, + B854ECF51FACC5FD006225B0 /* Info.plist */, + ); + path = TJBioAuthentication; + sourceTree = ""; + }; + B854ECFB1FACC633006225B0 /* Extensions */ = { + isa = PBXGroup; + children = ( + B854ECFC1FACC633006225B0 /* alertHelper.swift */, + B854ECFD1FACC633006225B0 /* keyBoardHelper.swift */, + ); + path = Extensions; + sourceTree = ""; + }; + B854ED071FACC65C006225B0 /* BioAuth */ = { + isa = PBXGroup; + children = ( + B854ED081FACC65C006225B0 /* TJAuthErrors.swift */, + B854ED091FACC65C006225B0 /* TJBioAuthenticator.swift */, + B854ED0A1FACC65C006225B0 /* TJDefaultMessages.swift */, + ); + path = BioAuth; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + B854ECE51FACC5FD006225B0 /* TJBioAuthentication */ = { + isa = PBXNativeTarget; + buildConfigurationList = B854ECF81FACC5FD006225B0 /* Build configuration list for PBXNativeTarget "TJBioAuthentication" */; + buildPhases = ( + B854ECE21FACC5FD006225B0 /* Sources */, + B854ECE31FACC5FD006225B0 /* Frameworks */, + B854ECE41FACC5FD006225B0 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = TJBioAuthentication; + productName = TJBioAuthentication; + productReference = B854ECE61FACC5FD006225B0 /* TJBioAuthentication.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + B854ECDE1FACC5FD006225B0 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0900; + LastUpgradeCheck = 0900; + ORGANIZATIONNAME = "Tejas Ardeshna"; + TargetAttributes = { + B854ECE51FACC5FD006225B0 = { + CreatedOnToolsVersion = 9.0; + ProvisioningStyle = Automatic; + }; + }; + }; + buildConfigurationList = B854ECE11FACC5FD006225B0 /* Build configuration list for PBXProject "TJBioAuthentication" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = B854ECDD1FACC5FD006225B0; + productRefGroup = B854ECE71FACC5FD006225B0 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + B854ECE51FACC5FD006225B0 /* TJBioAuthentication */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + B854ECE41FACC5FD006225B0 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B854ECF41FACC5FD006225B0 /* LaunchScreen.storyboard in Resources */, + B854ECF11FACC5FD006225B0 /* Assets.xcassets in Resources */, + B854ECEF1FACC5FD006225B0 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + B854ECE21FACC5FD006225B0 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + B854ED041FACC633006225B0 /* keyBoardHelper.swift in Sources */, + B854ECEC1FACC5FD006225B0 /* ViewController.swift in Sources */, + B854ED031FACC633006225B0 /* alertHelper.swift in Sources */, + B854ED0B1FACC65C006225B0 /* TJAuthErrors.swift in Sources */, + B854ED0C1FACC65C006225B0 /* TJBioAuthenticator.swift in Sources */, + B854ECEA1FACC5FD006225B0 /* AppDelegate.swift in Sources */, + B854ED0D1FACC65C006225B0 /* TJDefaultMessages.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + B854ECED1FACC5FD006225B0 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + B854ECEE1FACC5FD006225B0 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + B854ECF21FACC5FD006225B0 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + B854ECF31FACC5FD006225B0 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + B854ECF61FACC5FD006225B0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + B854ECF71FACC5FD006225B0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + B854ECF91FACC5FD006225B0 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = Y98X8JAPH6; + INFOPLIST_FILE = TJBioAuthentication/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.jalsa.TJBioAuthentication; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + B854ECFA1FACC5FD006225B0 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = Y98X8JAPH6; + INFOPLIST_FILE = TJBioAuthentication/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.jalsa.TJBioAuthentication; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + B854ECE11FACC5FD006225B0 /* Build configuration list for PBXProject "TJBioAuthentication" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B854ECF61FACC5FD006225B0 /* Debug */, + B854ECF71FACC5FD006225B0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + B854ECF81FACC5FD006225B0 /* Build configuration list for PBXNativeTarget "TJBioAuthentication" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + B854ECF91FACC5FD006225B0 /* Debug */, + B854ECFA1FACC5FD006225B0 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = B854ECDE1FACC5FD006225B0 /* Project object */; +} diff --git a/TJBioAuthentication/TJBioAuthentication.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/TJBioAuthentication/TJBioAuthentication.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..4c65fc3 --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/TJBioAuthentication/TJBioAuthentication/AppDelegate.swift b/TJBioAuthentication/TJBioAuthentication/AppDelegate.swift new file mode 100644 index 0000000..53db6b9 --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// TJBioAuthentication +// +// Created by Tejas Ardeshna on 03/11/17. +// Copyright © 2017 Tejas Ardeshna. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/TJBioAuthentication/TJBioAuthentication/Assets.xcassets/AppIcon.appiconset/Contents.json b/TJBioAuthentication/TJBioAuthentication/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000..1d060ed --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,93 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/TJBioAuthentication/TJBioAuthentication/Base.lproj/LaunchScreen.storyboard b/TJBioAuthentication/TJBioAuthentication/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000..f83f6fd --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TJBioAuthentication/TJBioAuthentication/Base.lproj/Main.storyboard b/TJBioAuthentication/TJBioAuthentication/Base.lproj/Main.storyboard new file mode 100644 index 0000000..9801997 --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication/Base.lproj/Main.storyboard @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TJBioAuthentication/TJBioAuthentication/BioAuth/TJAuthErrors.swift b/TJBioAuthentication/TJBioAuthentication/BioAuth/TJAuthErrors.swift new file mode 100755 index 0000000..37db4af --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication/BioAuth/TJAuthErrors.swift @@ -0,0 +1,93 @@ +// +// TJAuthErrors.swift +// BioAuth +// +// Created by Tejas Ardeshna on 03/11/17. +// Copyright © 2017 Tejas Ardeshna. +// +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation +import LocalAuthentication + +// Authentication Errors +public enum TJAuthErrors { + + case appCancel, failed, userCancel, userFallback, systemCancel, passcodeNotSet, biometryNotEnrolled, biometryLockedout, invalidContext , biometryNotAvailable,other + + public static func `init`(error: LAError) -> TJAuthErrors { + switch Int32(error.errorCode) { + + case kLAErrorAuthenticationFailed: + return failed + case kLAErrorUserCancel: + return userCancel + case kLAErrorUserFallback: + return userFallback + case kLAErrorSystemCancel: + return systemCancel + case kLAErrorPasscodeNotSet: + return passcodeNotSet + case kLAErrorBiometryNotEnrolled: + return biometryNotEnrolled + case kLAErrorBiometryLockout: + return biometryLockedout + case kLAErrorAppCancel: + return appCancel + case kLAErrorInvalidContext: + return invalidContext + case kLAErrorBiometryNotAvailable: + return biometryNotAvailable + default: + return other + } + } + + // get error message based on type + public func getMessage() -> String { + switch self { + case .appCancel: + return "Authentication was cancelled by application." + case .failed: + return "The user failed to provide valid credentials." + case .invalidContext: + return "The context is invalid." + case .userFallback: + return "The user chose to use the fallback." + case .userCancel: + return "The user did cance." + case .passcodeNotSet: + return "Passcode is not set on the device." + case .systemCancel: + return "Authentication was cancelled by the system." + case .biometryNotEnrolled: + return "Biometric is not enrolled on the device." + case .biometryLockedout: + return "Too many failed attempts." + case .biometryNotAvailable: + return "Biometric is not available on the device." + case .other: + return "Did not find error code on LAError object." + } + } +} + + diff --git a/TJBioAuthentication/TJBioAuthentication/BioAuth/TJBioAuthenticator.swift b/TJBioAuthentication/TJBioAuthentication/BioAuth/TJBioAuthenticator.swift new file mode 100755 index 0000000..844b8cb --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication/BioAuth/TJBioAuthenticator.swift @@ -0,0 +1,131 @@ +// +// TJBioAuthenticator.swift +// BioAuth +// +// Created by Tejas Ardeshna on 03/11/17. +// Copyright © 2017 Tejas Ardeshna. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import UIKit +import LocalAuthentication + +// success block +public typealias AuthenticationSuccess = (() -> ()) + +// failure block +public typealias AuthenticationFailure = ((TJAuthErrors) -> ()) + +open class TJBioAuthenticator: NSObject { + + struct Static { + static let instance = TJBioAuthenticator() + } + + // this is the Swift way to do singletons + class var shared: TJBioAuthenticator + { + return Static.instance + } +} + +// MARK:- Public + +public extension TJBioAuthenticator { + + // checks if Biometric Authentication is available on the device. + func isBiometricAuthenticationAvailable() -> Bool { + var error: NSError? = nil + + if LAContext().canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: &error) { + return (error == nil) + } + return false + } + + + // Biometric authentication + func authenticateUserWithBioMetrics(reason: String = "", fallbackTitle: String? = "", cancelTitle: String? = "", success successBlock:@escaping AuthenticationSuccess, failure failureBlock:@escaping AuthenticationFailure){ + let reasonString = reason.isEmpty ? TJBioAuthenticator.shared.defaultBiometricAuthenticationReason() : reason + + let context = LAContext() + context.localizedFallbackTitle = fallbackTitle + if #available(iOS 10.0, *) { + context.localizedCancelTitle = cancelTitle + } else { + // Fallback on earlier versions + } + + // evaluate policy + TJBioAuthenticator.shared.evaluate(policy: LAPolicy.deviceOwnerAuthenticationWithBiometrics, with: context, reason: reasonString, success: successBlock, failure: failureBlock) + } + + // Passcode authentication + func authenticateUserWithPasscode(reason: String = "", cancelTitle: String? = "", success successBlock:@escaping AuthenticationSuccess, failure failureBlock:@escaping AuthenticationFailure) { + let reasonString = reason.isEmpty ? TJBioAuthenticator.shared.defaultPasscodeAuthenticationReason() : reason + + let context = LAContext() + if #available(iOS 10.0, *) { + context.localizedCancelTitle = cancelTitle + } else { + // Fallback on earlier versions + } + + // evaluate policy + TJBioAuthenticator.shared.evaluate(policy: LAPolicy.deviceOwnerAuthentication, with: context, reason: reasonString, success: successBlock, failure: failureBlock) + } + + // checks if Face ID is avaiable on device + public func isFaceIDAvailable() -> Bool { + if #available(iOS 11.0, *) { + return (LAContext().biometryType == .typeFaceID) + } + return false + } +} + +// MARK:- evaluate policy +extension TJBioAuthenticator { + + func evaluate(policy: LAPolicy, with context: LAContext, reason: String, success successBlock:@escaping AuthenticationSuccess, failure failureBlock:@escaping AuthenticationFailure) { + + context.evaluatePolicy(policy, localizedReason: reason) { (success, err) in + if success { successBlock() } + else { + let errorType = TJAuthErrors(error: err as! LAError) + failureBlock(errorType) + } + } + } +} + +// MARK:- Get default messages +extension TJBioAuthenticator +{ + // get default bio authentication reason + func defaultBiometricAuthenticationReason() -> String { + return TJDefaultMessages.defaultReasonMessage.rawValue + } + + // get reason after too many failed attempts. + func defaultPasscodeAuthenticationReason() -> String { + return TJDefaultMessages.lockoutReasonMessage.rawValue + } +} diff --git a/TJBioAuthentication/TJBioAuthentication/BioAuth/TJDefaultMessages.swift b/TJBioAuthentication/TJBioAuthentication/BioAuth/TJDefaultMessages.swift new file mode 100644 index 0000000..0df4075 --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication/BioAuth/TJDefaultMessages.swift @@ -0,0 +1,35 @@ +// +// TJDefaultMessages.swift +// BioAuth +// +// Created by Tejas Ardeshna on 03/11/17. +// Copyright © 2017 Tejas Ardeshna. +// +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// + +import Foundation +import UIKit +enum TJDefaultMessages : String +{ + case defaultReasonMessage = "Authentication is needed to access your app." + case lockoutReasonMessage = "Too many failed attempts." +} + diff --git a/TJBioAuthentication/TJBioAuthentication/Extensions/alertHelper.swift b/TJBioAuthentication/TJBioAuthentication/Extensions/alertHelper.swift new file mode 100644 index 0000000..1bce34a --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication/Extensions/alertHelper.swift @@ -0,0 +1,21 @@ +// +// alertHelper.swift +// BioAuth +// +// Created by Tejas Ardeshna on 03/11/17. +// Copyright © 2017 Tejas Ardeshna. All rights reserved. +// + +import Foundation +import UIKit +extension UIViewController { + + func presentAlert(withTitle title: String, message : String) { + let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert) + let OKAction = UIAlertAction(title: "OK", style: .default) { action in + print("You've pressed OK Button") + } + alertController.addAction(OKAction) + self.present(alertController, animated: true, completion: nil) + } +} diff --git a/TJBioAuthentication/TJBioAuthentication/Extensions/keyBoardHelper.swift b/TJBioAuthentication/TJBioAuthentication/Extensions/keyBoardHelper.swift new file mode 100644 index 0000000..c146314 --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication/Extensions/keyBoardHelper.swift @@ -0,0 +1,27 @@ +// +// keyBoardHelper.swift +// BioAuth +// +// Created by Tejas Ardeshna on 03/11/17. +// Copyright © 2017 Tejas Ardeshna. All rights reserved. +// + +import Foundation +import UIKit + +extension UIViewController +{ + func hideKeyboard() + { + let tap: UITapGestureRecognizer = UITapGestureRecognizer( + target: self, + action: #selector(UIViewController.dismissKeyboard)) + + view.addGestureRecognizer(tap) + } + + @objc func dismissKeyboard() + { + view.endEditing(true) + } +} diff --git a/TJBioAuthentication/TJBioAuthentication/Info.plist b/TJBioAuthentication/TJBioAuthentication/Info.plist new file mode 100644 index 0000000..16be3b6 --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/TJBioAuthentication/TJBioAuthentication/ViewController.swift b/TJBioAuthentication/TJBioAuthentication/ViewController.swift new file mode 100644 index 0000000..476a2d2 --- /dev/null +++ b/TJBioAuthentication/TJBioAuthentication/ViewController.swift @@ -0,0 +1,64 @@ +// +// ViewController.swift +// TJBioAuthentication +// +// Created by Tejas Ardeshna on 03/11/17. +// Copyright © 2017 Tejas Ardeshna. All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + @IBOutlet weak var btnLoginWithBioMetric: UIButton! + @IBOutlet weak var btnLoginWithPassword: UIButton! + @IBOutlet weak var txtPassword: UITextField! + + @IBAction func btnBioAuthClicked(_ sender: Any) { + + TJBioAuthenticator.shared.authenticateUserWithBioMetrics(success: { + // Biometric Authentication success + self.showSucessAlert() + }) { (error) in + // Biometric Authentication unsuccessful + switch error{ + case .biometryLockedout: + self.executePasscodeAuthentication() + default: + self.presentAlert(withTitle: "Error", message: error.getMessage()) + break + } + } + } + + + override func viewDidLoad() { + super.viewDidLoad() + self.hideKeyboard() + // Do any additional setup after loading the view, typically from a nib. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + func executePasscodeAuthentication() + { + TJBioAuthenticator.shared.authenticateUserWithPasscode(success: { + self.showSucessAlert() + }) { (error) in + self.presentAlert(withTitle: "Error", message: error.getMessage()) + } + } +} + +extension ViewController +{ + func showSucessAlert() { + self.presentAlert(withTitle: "Success", message: "Login successful") + } +} + + + +