Class

SFAuthorizationView

The class responsible for displaying a lock icon that can be used to indicate that a user interface has restricted access.

Declaration

@interface SFAuthorizationView : NSView

Overview

The lock appears locked when the user must be authorized and appears open when the user has been authorized. The closed and open lock icons of the authorization view are shown in the following figure.

Figure 1

Authorization view lock icon

Authorization view lock icon

When you add an authorization view as a custom view to a window or dialog box, you must initialize it before it displays correctly. To initialize the view, use the setString: method to create a default rights structure (containing a prompt string) or the setAuthorizationRights: method to specify a rights structure. You must also either specify automatic updates (setAutoupdate: or setAutoupdate:interval:) or perform a manual update (updateStatus:) to set the lock icon to its initial state.

You can implement delegate methods that are invoked when the authorization view changes state. You can optionally implement the delegate methods to obtain the state of the authorization object when you are using an authorization view.

When the user clicks a locked authorization view icon, the Security Server displays an authentication dialog (to request a user name and password, for example). When the user provides the requested credentials, the lock icon unlocks and the user is considered preauthorized to perform the functions specified by the authorization rights structure. You can call the updateStatus: method to determine whether the user has been preauthorized: this method returns YES if the view is in the unlocked state, otherwise NO. Before committing changes or performing actions that require authorization, you should check the user’s authorization again, even if they are preauthorized.

The default behavior of this view is to preauthorize rights; if this is not possible it unlocks and waits for authorization to be checked when explicitly required.

Topics

Setting up the authorization view

- setString:

Sets the requested-right string to use with the default authorization rights set.

- setAuthorizationRights:

Sets the authorization rights for this view.

- setAutoupdate:

Sets the authorization view to update itself automatically.

- setAutoupdate:interval:

Sets the authorization view to update itself at a specific interval.

- setFlags:

Sets the current authorization flags for the view.

- setEnabled:

Sets the current state of the authorization view.

Setting and getting the delegate for the view

- setDelegate:

Sets the delegate for this authorization view.

- delegate

Returns the delegate for this view.

Updating the view

- updateStatus:

Manually updates the authorization view.

Getting information about the authorization view

- authorization

Returns the authorization object associated with this view.

- authorizationRights

Returns the authorization rights for this view.

- authorizationState

Returns the current state of the authorization view.

- isEnabled

Indicates whether the authorization view is enabled (YES) or disabled (NO).

Setting the authorization state

- authorize:

Attempts to unlock the lock icon in the view.

- deauthorize:

Sets the authorization state to unauthorized and locks the lock icon in the view.

Delegate methods

- authorizationViewShouldDeauthorize:

Sent to the delegate when a user clicks the open lock icon.

- authorizationViewCreatedAuthorization:

Sent to the delegate to indicate the authorization object has been created or changed. If you have saved a copy of the authorization object for your own purposes, you should discard it and call authorization for a new authorization object.

- authorizationViewDidAuthorize:

Sent to the delegate to indicate the user was authorized and the authorization view was changed to unlocked.

- authorizationViewDidDeauthorize:

Sent to the delegate to indicate the user was deauthorized and the authorization view was changed to locked.

- authorizationViewDidHide:

Sent to the delegate to indicate that the view’s visibility has changed.

- authorizationViewReleasedAuthorization:

Sent to the delegate to indicate that deauthorization is about to occur.

Constants

SFAuthorizationViewState

Defines the current state of the authorization view.

Relationships

Inherits From