Skip to main content
Previous sectionNext section

Code for Authorization Example

Here is the code for the authentication example. Create the class using Atelier.

Class SecurityTutorial.AuthorizationExample
{
ClassMethod CreateTestData()
{
    Set ^TestData = "MyInitialData"
}

ClassMethod HelloUser()
{
    Write "User ", $Username
}

ClassMethod UpdateTestData()
{
    Set ^TestData = "MyUpdatedData"
}

ClassMethod ReadTestData() As %String
{
    Return ^TestData
}

ClassMethod ProtectedMethod() As %String
{
    If ($System.Security.Check("ProtectedMethod","U"))
    {
        Return $Username
    }
    Else
    {
        Return "Error: Insufficient Privileges"
    }
}

}
Copy code to clipboard
Note:

For more information about Atelier, including instructions for downloading and installing, as well as videos and tutorials on how to use it, see Atelier Download