Class TokenCredentials

  • All Implemented Interfaces:
    java.io.Serializable, Credentials

    public final class TokenCredentials
    extends java.lang.Object
    implements Credentials
    TokenCredentials implements the Credentials interface and represents single token credentials. Similar to SimpleCredentials this credentials implementation allows to set additional attributes.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      TokenCredentials​(@NotNull java.lang.String token)
      Create a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      @Nullable java.lang.String getAttribute​(@NotNull java.lang.String name)
      Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
      @NotNull java.lang.String[] getAttributeNames()
      Returns the names of the attributes available to this credentials instance.
      @NotNull java.lang.String getToken()
      Returns the token this credentials are built from.
      void removeAttribute​(@NotNull java.lang.String name)
      Removes an attribute from this credentials instance.
      void setAttribute​(@NotNull java.lang.String name, @Nullable java.lang.String value)
      Stores an attribute in this credentials instance.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TokenCredentials

        public TokenCredentials​(@NotNull
                                @NotNull java.lang.String token)
                         throws java.lang.IllegalArgumentException
        Create a new instance.
        Parameters:
        token - A token string used to create this credentials instance.
        Throws:
        java.lang.IllegalArgumentException - If the specified token is null or empty string.
    • Method Detail

      • getToken

        @NotNull
        public @NotNull java.lang.String getToken()
        Returns the token this credentials are built from.
        Returns:
        the token.
      • setAttribute

        public void setAttribute​(@NotNull
                                 @NotNull java.lang.String name,
                                 @Nullable
                                 @Nullable java.lang.String value)
        Stores an attribute in this credentials instance.
        Parameters:
        name - a String specifying the name of the attribute
        value - the Object to be stored
      • getAttribute

        @Nullable
        public @Nullable java.lang.String getAttribute​(@NotNull
                                                       @NotNull java.lang.String name)
        Returns the value of the named attribute as an Object, or null if no attribute of the given name exists.
        Parameters:
        name - a String specifying the name of the attribute
        Returns:
        an Object containing the value of the attribute, or null if the attribute does not exist
      • removeAttribute

        public void removeAttribute​(@NotNull
                                    @NotNull java.lang.String name)
        Removes an attribute from this credentials instance.
        Parameters:
        name - a String specifying the name of the attribute to remove
      • getAttributeNames

        @NotNull
        public @NotNull java.lang.String[] getAttributeNames()
        Returns the names of the attributes available to this credentials instance. This method returns an empty array if the credentials instance has no attributes available to it.
        Returns:
        a string array containing the names of the stored attributes