Class Auth.TokenRequest

  • All Implemented Interfaces:
    java.io.Serializable
    Enclosing class:
    Auth

    public static class Auth.TokenRequest
    extends java.lang.Object
    implements java.io.Serializable

    A container for all of the options that can be passed to the createToken(TokenRequest) method, to avoid that method having an excessive number of parameters (with null typically passed to most of them).

    All properties here are optional. Use of this class resembles a builder pattern (i.e. call the mutator method for each property you wish to set), but this class lacks a final build() method as no post-initialization logic is necessary.

    See Also:
    Serialized Form
    • Constructor Detail

      • TokenRequest

        public TokenRequest()
    • Method Detail

      • id

        public Auth.TokenRequest id​(java.util.UUID id)
        Parameters:
        id - (optional) The ID of the client token. Can only be specified by a root token. Otherwise, the token ID is a randomly generated UUID.
        Returns:
        This object, with its id field populated
      • polices

        public Auth.TokenRequest polices​(java.util.List<java.lang.String> polices)
        Parameters:
        polices - (optional) A list of policies for the token. This must be a subset of the policies belonging to the token
        Returns:
        This object, with its polices field populated
      • meta

        public Auth.TokenRequest meta​(java.util.Map<java.lang.String,​java.lang.String> meta)
        Parameters:
        meta - (optional) A map of string to string valued metadata. This is passed through to the audit backends.
        Returns:
        This object, with its meta field populated
      • noParent

        public Auth.TokenRequest noParent​(java.lang.Boolean noParent)
        Parameters:
        noParent - (optional) If true and set by a root caller, the token will not have the parent token of the caller. This creates a token with no parent.
        Returns:
        This object, with its noParent field populated
      • noDefaultPolicy

        public Auth.TokenRequest noDefaultPolicy​(java.lang.Boolean noDefaultPolicy)
        Parameters:
        noDefaultPolicy - (optional) If true the default policy will not be a part of this token's policy set.
        Returns:
        This object, with its noDefaultPolicy field populated
      • ttl

        public Auth.TokenRequest ttl​(java.lang.String ttl)
        Parameters:
        ttl - (optional) The TTL period of the token, provided as "1h", where hour is the largest suffix. If not provided, the token is valid for the default lease TTL, or indefinitely if the root policy is used.
        Returns:
        This object, with its ttl field populated
      • displayName

        public Auth.TokenRequest displayName​(java.lang.String displayName)
        Parameters:
        displayName - (optional) The display name of the token. Defaults to "token".
        Returns:
        This object, with its displayName field populated
      • numUses

        public Auth.TokenRequest numUses​(java.lang.Long numUses)
        Parameters:
        numUses - (optional) The maximum uses for the given token. This can be used to create a one-time-token or limited use token. Defaults to 0, which has no limit to the number of uses.
        Returns:
        This object, with its numUses field populated
      • role

        public Auth.TokenRequest role​(java.lang.String role)
        Parameters:
        role - (optional) The role the token will be created with. Default is no role.
        Returns:
        This object, with its role field populated
      • getId

        public java.util.UUID getId()
      • getPolices

        public java.util.List<java.lang.String> getPolices()
      • getMeta

        public java.util.Map<java.lang.String,​java.lang.String> getMeta()
      • getNoParent

        public java.lang.Boolean getNoParent()
      • getNoDefaultPolicy

        public java.lang.Boolean getNoDefaultPolicy()
      • getTtl

        public java.lang.String getTtl()
      • getDisplayName

        public java.lang.String getDisplayName()
      • getNumUses

        public java.lang.Long getNumUses()
      • getRole

        public java.lang.String getRole()