Class Subject.Builder

java.lang.Object
io.helidon.security.Subject.Builder
All Implemented Interfaces:
Builder<Subject.Builder,Subject>, Supplier<Subject>
Enclosing class:
Subject

public static final class Subject.Builder extends Object implements Builder<Subject.Builder,Subject>
A fluent API builder for Subject.
  • Method Details

    • build

      public Subject build()
      Description copied from interface: Builder
      Build the instance from this builder.
      Specified by:
      build in interface Builder<Subject.Builder,Subject>
      Returns:
      instance of the built type
    • update

      public Subject.Builder update(Subject subject)
      Update this builder with all security information from the subject provided.
      Parameters:
      subject - subject to copy information from
      Returns:
      updated builder instance
    • principal

      public Subject.Builder principal(Principal principal)
      Main principal of this subject.
      Parameters:
      principal - principal (e.g. a user or a service)
      Returns:
      updated builder instance
    • addGrant

      public Subject.Builder addGrant(Grant grant)
      Add a grant to this subject.
      Parameters:
      grant - grant to add (e.g. a role, scope, permission etc.)
      Returns:
      updated builder instance
    • addPublicCredential

      public Subject.Builder addPublicCredential(Class<?> className, Object instance)
      Add a public credential to this subject. Only one instance of a type may be added to a subject.
      Parameters:
      className - class of the credential (e.g. X509 certificate)
      instance - instance of the credential
      Returns:
      updated builder instance
    • addPublicCredential

      public Subject.Builder addPublicCredential(Object instance)
      Add a public credential to this subject to be bound under its class.
      Parameters:
      instance - instance of the credential, the class it will be bound to is obtained through instance.getClass()
      Returns:
      updated builder instance
    • addPrivateCredential

      public Subject.Builder addPrivateCredential(Class<?> className, Object instance)
      Add a private credential to this subject. Only one instance of a type may be added to a subject.
      Parameters:
      className - class of the credential (e.g. X509 certificate)
      instance - instance of the credential
      Returns:
      updated builder instance
    • addPrivateCredential

      public Subject.Builder addPrivateCredential(Object instance)
      Add a private credential to this subject to be bound under its class.
      Parameters:
      instance - instance of the credential, the class it will be bound to is obtained through instance.getClass()
      Returns:
      updated builder instance
    • attributes

      public Subject.Builder attributes(AbacSupport attributes)
      Add all attributes to this subject. Attributes can extend information with data not fitting to other fields of this subject.
      Parameters:
      attributes - attributes with key/value pairs
      Returns:
      updated builder instance
    • addAttribute

      public Subject.Builder addAttribute(String key, Object value)
      Add an attribute to this subject.
      Parameters:
      key - name of the attribute
      value - value of the attribute
      Returns:
      updated builder instance
    • addPrincipal

      public Subject.Builder addPrincipal(Principal principal)
      Add a principal to the list of principals of this subject. If principal(Principal) was not invoked prior to this method, it will also set the "main" principal.
      Parameters:
      principal - principal to add to this subject
      Returns:
      updated builder instance