Class AccessPolicy.Builder

java.lang.Object
org.apache.nifi.authorization.AccessPolicy.Builder
Enclosing class:
AccessPolicy

public static class AccessPolicy.Builder extends Object
Builder for Access Policies.
  • Field Details

    • identifier

      private String identifier
    • resource

      private String resource
    • action

      private RequestAction action
    • users

      private Set<String> users
    • groups

      private Set<String> groups
    • fromPolicy

      private final boolean fromPolicy
  • Constructor Details

    • Builder

      public Builder()
      Default constructor for building a new AccessPolicy.
    • Builder

      public Builder(AccessPolicy other)
      Initializes the builder with the state of the provided policy. When using this constructor the identifier field of the builder can not be changed and will result in an IllegalStateException if attempting to do so.
      Parameters:
      other - the existing access policy to initialize from
  • Method Details

    • identifier

      public AccessPolicy.Builder identifier(String identifier)
      Sets the identifier of the builder.
      Parameters:
      identifier - the identifier to set
      Returns:
      the builder
      Throws:
      IllegalStateException - if this method is called when this builder was constructed from an existing Policy
    • identifierGenerateRandom

      public AccessPolicy.Builder identifierGenerateRandom()
      Sets the identifier of the builder to a random UUID.
      Returns:
      the builder
      Throws:
      IllegalStateException - if this method is called when this builder was constructed from an existing Policy
    • identifierGenerateFromSeed

      public AccessPolicy.Builder identifierGenerateFromSeed(String seed)
      Sets the identifier of the builder with a UUID generated from the specified seed string.
      Returns:
      the builder
      Throws:
      IllegalStateException - if this method is called when this builder was constructed from an existing Policy
    • resource

      public AccessPolicy.Builder resource(String resource)
      Sets the resource of the builder.
      Parameters:
      resource - the resource to set
      Returns:
      the builder
    • addUsers

      public AccessPolicy.Builder addUsers(Set<String> users)
      Adds all the users from the provided set to the builder's set of users.
      Parameters:
      users - the users to add
      Returns:
      the builder
    • addUser

      public AccessPolicy.Builder addUser(String user)
      Adds the given user to the builder's set of users.
      Parameters:
      user - the user to add
      Returns:
      the builder
    • removeUsers

      public AccessPolicy.Builder removeUsers(Set<String> users)
      Removes all users in the provided set from the builder's set of users.
      Parameters:
      users - the users to remove
      Returns:
      the builder
    • removeUser

      public AccessPolicy.Builder removeUser(String user)
      Removes the provided user from the builder's set of users.
      Parameters:
      user - the user to remove
      Returns:
      the builder
    • clearUsers

      public AccessPolicy.Builder clearUsers()
      Clears the builder's set of users so that it is non-null and size == 0.
      Returns:
      the builder
    • addGroups

      public AccessPolicy.Builder addGroups(Set<String> groups)
      Adds all the groups from the provided set to the builder's set of groups.
      Parameters:
      groups - the groups to add
      Returns:
      the builder
    • addGroup

      public AccessPolicy.Builder addGroup(String group)
      Adds the given group to the builder's set of groups.
      Parameters:
      group - the group to add
      Returns:
      the builder
    • removeGroups

      public AccessPolicy.Builder removeGroups(Set<String> groups)
      Removes all groups in the provided set from the builder's set of groups.
      Parameters:
      groups - the groups to remove
      Returns:
      the builder
    • removeGroup

      public AccessPolicy.Builder removeGroup(String group)
      Removes the provided groups from the builder's set of groups.
      Parameters:
      group - the group to remove
      Returns:
      the builder
    • clearGroups

      public AccessPolicy.Builder clearGroups()
      Clears the builder's set of groups so that it is non-null and size == 0.
      Returns:
      the builder
    • action

      public AccessPolicy.Builder action(RequestAction action)
      Sets the action for this builder.
      Parameters:
      action - the action to set
      Returns:
      the builder
    • build

      public AccessPolicy build()
      Returns:
      a new AccessPolicy constructed from the state of the builder