java.lang.Object
de.stklcode.jvault.connector.model.Token.Builder
Enclosing class:
Token

public static final class Token.Builder extends Object
A builder for vault tokens.
Since:
0.4.0, 0.9 Moved into subclass of Token.
Author:
Stefan Kalscheuer
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • withId

      public Token.Builder withId(String id)
      Add token ID. (optional)
      Parameters:
      id - the ID
      Returns:
      self
    • withType

      public Token.Builder withType(Token.Type type)
      Specify token type.
      Parameters:
      type - the type
      Returns:
      self
      Since:
      0.9
    • withDisplayName

      public Token.Builder withDisplayName(String displayName)
      Add display name.
      Parameters:
      displayName - the display name
      Returns:
      self
    • withTtl

      public Token.Builder withTtl(Integer ttl)
      Set desired time to live.
      Parameters:
      ttl - the ttl
      Returns:
      self
    • withExplicitMaxTtl

      public Token.Builder withExplicitMaxTtl(Integer explicitMaxTtl)
      Set desired explicit maximum time to live.
      Parameters:
      explicitMaxTtl - the explicit max. TTL
      Returns:
      self
    • withNumUses

      public Token.Builder withNumUses(Integer numUses)
      Set desired number of uses.
      Parameters:
      numUses - the number of uses
      Returns:
      self
    • withNoParent

      public Token.Builder withNoParent(boolean noParent)
      Set TRUE if the token should be created without parent.
      Parameters:
      noParent - if TRUE, token is created as orphan
      Returns:
      self
    • asOrphan

      public Token.Builder asOrphan()
      Create token without parent. Convenience method for withNoParent()
      Returns:
      self
    • withParent

      public Token.Builder withParent()
      Create token with parent. Convenience method for withNoParent()
      Returns:
      self
    • withNoDefaultPolicy

      public Token.Builder withNoDefaultPolicy(boolean noDefaultPolicy)
      Set TRUE if the default policy should not be part of this token.
      Parameters:
      noDefaultPolicy - if TRUE, default policy is not attached
      Returns:
      self
    • withDefaultPolicy

      public Token.Builder withDefaultPolicy()
      Attach default policy to token. Convenience method for withNoDefaultPolicy()
      Returns:
      self
    • withoutDefaultPolicy

      public Token.Builder withoutDefaultPolicy()
      Do not attach default policy to token. Convenience method for withNoDefaultPolicy()
      Returns:
      self
    • withPolicies

      public Token.Builder withPolicies(String... policies)
      Add given policies.
      Parameters:
      policies - the policies
      Returns:
      self
      Since:
      0.5.0
    • withPolicies

      public Token.Builder withPolicies(List<String> policies)
      Add given policies.
      Parameters:
      policies - the policies
      Returns:
      self
    • withPolicy

      public Token.Builder withPolicy(String policy)
      Add a single policy.
      Parameters:
      policy - the policy
      Returns:
      self
    • withMeta

      public Token.Builder withMeta(Map<String,String> meta)
      Add meta data.
      Parameters:
      meta - the metadata
      Returns:
      self
    • withMeta

      public Token.Builder withMeta(String key, String value)
      Add meta data.
      Parameters:
      key - the key
      value - the value
      Returns:
      self
    • withRenewable

      public Token.Builder withRenewable(Boolean renewable)
      Set if token is renewable.
      Parameters:
      renewable - TRUE, if renewable
      Returns:
      self
    • renewable

      public Token.Builder renewable()
      Set token to be renewable. Convenience method for withRenewable()
      Returns:
      self
    • notRenewable

      public Token.Builder notRenewable()
      Set token to be not renewable. Convenience method for withRenewable()
      Returns:
      self
    • withPeriod

      public Token.Builder withPeriod(Integer period)
      Set token period (former lease time).
      Parameters:
      period - Period in seconds.
      Returns:
      self
    • withEntityAlias

      public Token.Builder withEntityAlias(String entityAlias)
      Set entity alias for token. Only works in combination with an associated token role.
      Parameters:
      entityAlias - Entity alias.
      Returns:
      self
    • build

      public Token build()
      Build the token based on given parameters.
      Returns:
      the token