Discuss about imperative and declarative security.
Declarative security : Security requests are made in form of attributes.
Example:<MyPermission(SecurityAction.Demand, Unrestricted = True)>
Public Class MyCustomClass
Public Sub New()
'The constructor is protected by the security call.
End Sub
Public Sub Method1()
'This method is protected by the security call.
End Sub
Public Sub Method2()
'This method is protected by the security call.
End Sub
End Class
Imperative security : Security requests are made in the form of lines of code within a method body.Basically an instance of permission object is created that needs to be invoked.
Example:Public Class MyCustomClass
Public Sub New()
End Sub
Public Sub Method1()
'MyPermission is demanded using imperative syntax.
Dim permission As New MyPermission()
permission.Demand()
'This method is protected by the security call.
End Sub
Public Sub Method2()
'YourMethod 'This method is not protected by the security call.
End Sub
End Class