Platforms to show: All Mac Windows Linux Cross-Platform
/Mac64bit/Local Authentication
Required plugins for this example: MBS Mac64bit Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Mac64bit/Local Authentication
This example is the version from Tue, 21th Jan 2019.
Project "Local Authentication.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
if TargetMacOS and Target64Bit then
// ok
else
MsgBox "Please built as 64-bit Mac application. "
quit
end if
End EventHandler
End Class
Class MainWindow Inherits Window
Control CheckButton Inherits PushButton
ControlInstance CheckButton Inherits PushButton
EventHandler Sub Action()
try
dim e as NSErrorMBS
if lc.canEvaluatePolicy(lc.PolicyDeviceOwnerAuthentication, e) then
List.AddRow "Can authenticate."
else
List.AddRow "Can't authenticate."
end if
if e <> nil then
List.AddRow "Error: "+e.LocalizedDescription
end if
catch ex as NSExceptionMBS
List.AddRow "Exception: "+ex.Message
end try
try
dim e as NSErrorMBS
if lc.canEvaluatePolicy(lc.PolicyDeviceOwnerAuthenticationWithBiometrics, e) then
List.AddRow "Can authenticate with biometrics."
else
List.AddRow "Can't authenticate with biometrics."
end if
if e <> nil then
List.AddRow "Error: "+e.LocalizedDescription
end if
catch ex as NSExceptionMBS
List.AddRow "Exception: "+ex.Message
end try
End EventHandler
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control EvaluateButton Inherits PushButton
ControlInstance EvaluateButton Inherits PushButton
EventHandler Sub Action()
try
lc.evaluatePolicy(lc.PolicyDeviceOwnerAuthentication, "We need to test.")
catch ex as NSExceptionMBS
List.AddRow "Exception: "+ex.Message
end try
End EventHandler
End Control
Control EvaluateButton1 Inherits PushButton
ControlInstance EvaluateButton1 Inherits PushButton
EventHandler Sub Action()
try
lc.evaluatePolicy(lc.PolicyDeviceOwnerAuthenticationWithBiometrics, "We need to test.")
catch ex as NSExceptionMBS
List.AddRow "Exception: "+ex.Message
end try
End EventHandler
End Control
EventHandler Sub Close()
if lc <> nil then
lc.invalidate
lc = nil
end if
End EventHandler
EventHandler Sub Open()
if not LAContextMBS.Available then
MsgBox "Local Authentication is not available."
quit
end if
lc = new MyLAContextMBS
lc.list = List
lc.localizedFallbackTitle = "Just a test"
End EventHandler
Property lc As MyLAContextMBS
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyLAContextMBS Inherits LAContextMBS
EventHandler Sub evaluatePolicyResult(Success as Boolean, error as NSErrorMBS, Policy as Integer, localizedReason as String, tag as Variant)
list.AddRow CurrentMethodName
list.AddRow "success: "+str(Success)
if error <> nil then
list.AddRow "Error: "+error.LocalizedDescription
end if
End EventHandler
Property list As listbox
End Class
End Project
The items on this page are in the following plugins: MBS Mac64bit Plugin.