de.esprit.netsuite.server.permission

## Class ServerPermissionConfig

- java.lang.Object
- - de.esprit.common.util.DumpableObject
  - - de.esprit.common.util.TransferableObject
    - - de.esprit.netsuite.server.config.AbstractServerConfig
      - - de.esprit.netsuite.server.permission.ServerPermissionConfig

- All Implemented Interfaces:
    Clearable, DeepCloneable, Dumpable, PermissionConfig, java.io.Serializable, java.lang.Cloneable

      public class ServerPermissionConfig
      extends AbstractServerConfig
      implements PermissionConfig

  This class encapsulates the configuration of user and group access permissions stored in the server config file `ServerFile.PERMISSION_CFG`. User and group permissions are defined in different lists whereas group permissions are only checked if a requested user permission was not found. Note that group permissions only take effect, if a `GroupResolver` instance was installed using `setGroupResolver(GroupResolver)`.
  Author:
    Rainer Buesch
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `accessibleObjectKey`
    `static java.lang.String` | `groupNameKey`
    `static java.lang.String` | `groupPermissionsTable`
    `static java.lang.String` | `permissionConfigType`
    `static java.lang.String` | `permissionKey`
    `static java.lang.String` | `userNameKey`
    `static java.lang.String` | `userPermissionsTable`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServerPermissionConfig()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `addGroupPermission(GroupPermissionEntry entry)`
    `boolean` | `addUserPermission(UserPermissionEntry entry)`
    `void` | `checkGroupPermission(Group group, PermissionControlled obj, UserPermission action)` Same as `PermissionConfig.hasGroupPermission(Group, PermissionControlled, UserPermission)` but throws an exception if the permission was not granted.
    `void` | `checkUserPermission(UserId userId, PermissionControlled obj, UserPermission action)` Same as `PermissionConfig.hasUserPermission(UserId, PermissionControlled, UserPermission)` but throws an exception if the permission was not granted.
    `void` | `clear()` Clears the content
    `void` | `clearGroupPermissions()`
    `void` | `clearUserPermissions()`
    `java.util.List<GroupPermissionEntry>` | `findGroupPermissionsFor(Group group)`
    `java.util.List<UserPermissionEntry>` | `findUserPermissionsFor(UserId userId)`
    `java.util.List<GroupPermissionEntry>` | `getGroupPermissions()`
    `java.util.List<UserPermissionEntry>` | `getUserPermissions()`
    `boolean` | `hasGroupPermission(Group group, PermissionControlled obj, UserPermission action)` Tells whether the given group may perform the given action on the given object.
    `protected boolean` | `hasPrivilegedUserPermission(UserId userId)` Defines if this user has particular privileges.
    `boolean` | `hasUserPermission(UserId userId, PermissionControlled obj, UserPermission action)` Tells whether the given user may perform the given action on the given object.
    `void` | `read(ApplicationContext ctx, java.io.File inputFile)`
    `int` | `removeGroupPermissionsFor(Group group)` Removes all permissions of this group
    `int` | `removeUserPermissionsFor(UserId userId)` Removes all permissions of this user
    `boolean` | `setGroupPermission(Group group, PermissionDefinition obj, UserPermission... actions)` Adds a new permission, whereas a `PermissionEntry` is created from the given arguments.
    `void` | `setGroupResolver(GroupResolver groupResolver)` Installs an instance that can find out the according `Group` of a `UserId`.
    `boolean` | `setUserPermission(UserId userId, PermissionDefinition obj, UserPermission... actions)` Adds a new permission, whereas a `PermissionEntry` is created from the given arguments.
    `DumpString` | `toDumpString(DumpString s)` This method allows subclasses to add values to the existing DumpString of the superclass.
    `ToString` | `toString(ToString s)` This method allows subclasses to add values to the existing ToString of the superclass.
    `void` | `write(ApplicationContext ctx, java.io.File outputFile)`

    - ### Methods inherited from class de.esprit.netsuite.server.config.AbstractServerConfig

      `equals, getConfigFileIn, getConfigFileName, hashCode, read, write`

    - ### Methods inherited from class de.esprit.common.util.TransferableObject

      `clone, copy`

    - ### Methods inherited from class de.esprit.common.util.DumpableObject

      `configureDumpHeadlineLength, configureDumpMaxElementsPrinted, copyDumpStringValues, copyToStringValues, createDumpHeader, toDumpString, toString`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### permissionConfigType

          public static final java.lang.String permissionConfigType

      See Also:
        Constant Field Values

    - #### userPermissionsTable

          public static final java.lang.String userPermissionsTable

      See Also:
        Constant Field Values

    - #### groupPermissionsTable

          public static final java.lang.String groupPermissionsTable

      See Also:
        Constant Field Values

    - #### groupNameKey

          public static final java.lang.String groupNameKey

      See Also:
        Constant Field Values

    - #### userNameKey

          public static final java.lang.String userNameKey

      See Also:
        Constant Field Values

    - #### accessibleObjectKey

          public static final java.lang.String accessibleObjectKey

      See Also:
        Constant Field Values

    - #### permissionKey

          public static final java.lang.String permissionKey

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ServerPermissionConfig

          public ServerPermissionConfig()

  - ### Method Detail

    - #### setGroupResolver

          public void setGroupResolver(GroupResolver groupResolver)

      Installs an instance that can find out the according `Group` of a `UserId`. If this instance is not set, no check for group-permissions will take place.

    - #### getUserPermissions

          public final java.util.List<UserPermissionEntry> getUserPermissions()

    - #### addUserPermission

          public final boolean addUserPermission(UserPermissionEntry entry)

    - #### setUserPermission

          public final boolean setUserPermission(UserId userId,
                                  PermissionDefinition obj,
                                  UserPermission... actions)

      Description copied from interface: `PermissionConfig`
      Adds a new permission, whereas a `PermissionEntry` is created from the given arguments.
      Specified by:
        `setUserPermission` in interface `PermissionConfig`

    - #### findUserPermissionsFor

          public final java.util.List<UserPermissionEntry> findUserPermissionsFor(UserId userId)

    - #### hasUserPermission

          public final boolean hasUserPermission(UserId userId,
                                  PermissionControlled obj,
                                  UserPermission action)

      Description copied from interface: `PermissionConfig`
      Tells whether the given user may perform the given action on the given object.
      Specified by:
        `hasUserPermission` in interface `PermissionConfig`
      See Also:
        `PermissionConfig.checkUserPermission(UserId, PermissionControlled, UserPermission)`

    - #### checkUserPermission

          public final void checkUserPermission(UserId userId,
                                 PermissionControlled obj,
                                 UserPermission action)
                                         throws PermissionException

      Description copied from interface: `PermissionConfig`
      Same as `PermissionConfig.hasUserPermission(UserId, PermissionControlled, UserPermission)` but throws an exception if the permission was not granted.
      Specified by:
        `checkUserPermission` in interface `PermissionConfig`
      Throws:
        `PermissionException`

    - #### removeUserPermissionsFor

          public final int removeUserPermissionsFor(UserId userId)

      Removes all permissions of this user
      Returns:
        the number of permissions actually removed

    - #### clearUserPermissions

          public final void clearUserPermissions()

    - #### getGroupPermissions

          public final java.util.List<GroupPermissionEntry> getGroupPermissions()

    - #### setGroupPermission

          public final boolean setGroupPermission(Group group,
                                   PermissionDefinition obj,
                                   UserPermission... actions)

      Description copied from interface: `PermissionConfig`
      Adds a new permission, whereas a `PermissionEntry` is created from the given arguments.
      Specified by:
        `setGroupPermission` in interface `PermissionConfig`

    - #### addGroupPermission

          public final boolean addGroupPermission(GroupPermissionEntry entry)

    - #### findGroupPermissionsFor

          public final java.util.List<GroupPermissionEntry> findGroupPermissionsFor(Group group)

    - #### hasGroupPermission

          public final boolean hasGroupPermission(Group group,
                                   PermissionControlled obj,
                                   UserPermission action)

      Description copied from interface: `PermissionConfig`
      Tells whether the given group may perform the given action on the given object.
      Specified by:
        `hasGroupPermission` in interface `PermissionConfig`
      See Also:
        `PermissionConfig.checkGroupPermission(Group, PermissionControlled, UserPermission)`

    - #### checkGroupPermission

          public final void checkGroupPermission(Group group,
                                  PermissionControlled obj,
                                  UserPermission action)
                                          throws PermissionException

      Description copied from interface: `PermissionConfig`
      Same as `PermissionConfig.hasGroupPermission(Group, PermissionControlled, UserPermission)` but throws an exception if the permission was not granted.
      Specified by:
        `checkGroupPermission` in interface `PermissionConfig`
      Throws:
        `PermissionException`

    - #### hasPrivilegedUserPermission

          protected boolean hasPrivilegedUserPermission(UserId userId)

      Defines if this user has particular privileges. If this method returns true, then the user is granted permission no matter what other permissions are configured.

    - #### removeGroupPermissionsFor

          public final int removeGroupPermissionsFor(Group group)

      Removes all permissions of this group
      Returns:
        the number of permissions actually removed

    - #### clearGroupPermissions

          public final void clearGroupPermissions()

    - #### clear

          public final void clear()

      Description copied from interface: `Clearable`
      Clears the content
      Specified by:
        `clear` in interface `Clearable`

    - #### read

          public final void read(ApplicationContext ctx,
                  java.io.File inputFile)
                          throws java.lang.Exception

      Specified by:
        `read` in class `AbstractServerConfig`
      Throws:
        `java.lang.Exception`

    - #### write

          public final void write(ApplicationContext ctx,
                   java.io.File outputFile)
                           throws java.lang.Exception

      Specified by:
        `write` in class `AbstractServerConfig`
      Throws:
        `java.lang.Exception`

    - #### toString

          public final ToString toString(ToString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing ToString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toString` in interface `Dumpable`
      Overrides:
        `toString` in class `AbstractServerConfig`

    - #### toDumpString

          public final DumpString toDumpString(DumpString s)

      Description copied from interface: `Dumpable`
      This method allows subclasses to add values to the existing DumpString of the superclass. Usually subclasses only need to override this method.
      Specified by:
        `toDumpString` in interface `Dumpable`
      Overrides:
        `toDumpString` in class `DumpableObject`

Copyright © 2013 EsprIT-Systems. All Rights Reserved.