Class DefaultSecurityTokenService

java.lang.Object
net.solarnetwork.service.support.BasicIdentifiable
net.solarnetwork.node.service.support.BaseIdentifiable
net.solarnetwork.node.runtime.DefaultSecurityTokenService
All Implemented Interfaces:
SecurityTokenService, net.solarnetwork.service.Identifiable

public class DefaultSecurityTokenService extends BaseIdentifiable implements SecurityTokenService
Default implementation of SecurityTokenService
Since:
3.4
Version:
1.0
Author:
matt
  • Constructor Details

    • DefaultSecurityTokenService

      public DefaultSecurityTokenService(net.solarnetwork.service.OptionalService<SecurityTokenDao> securityTokenDao)
      Constructor.
      Parameters:
      securityTokenDao - the DAO to use
      Throws:
      IllegalArgumentException - if any argument is null
    • DefaultSecurityTokenService

      public DefaultSecurityTokenService(SecureRandom rng, net.solarnetwork.service.OptionalService<SecurityTokenDao> securityTokenDao)
      Constructor.
      Parameters:
      rng - the random number generator
      securityTokenDao - the DAO to use
      Throws:
      IllegalArgumentException - if any argument is null
  • Method Details

    • getAvailableTokens

      public Collection<SecurityToken> getAvailableTokens()
      Description copied from interface: SecurityTokenService
      Get all available security tokens.

      The token secrets are not returned by this method.

      Specified by:
      getAvailableTokens in interface SecurityTokenService
      Returns:
      the tokens, never null
    • tokenForId

      public SecurityToken tokenForId(String tokenId)
      Description copied from interface: SecurityTokenService
      Get a security token for a given ID.
      Specified by:
      tokenForId in interface SecurityTokenService
      Parameters:
      tokenId - the token ID
      Returns:
      the token, or null if not found
    • createToken

      public net.solarnetwork.domain.KeyValuePair createToken(SecurityToken details)
      Description copied from interface: SecurityTokenService
      Create a new token.

      This method will generate a new security token and return the generated token ID and secret.

      Specified by:
      createToken in interface SecurityTokenService
      Parameters:
      details - the optional details (name, description) to use
      Returns:
      the token ID and token secret
    • updateToken

      public void updateToken(SecurityToken token)
      Description copied from interface: SecurityTokenService
      Update the modifiable values of a security token.

      The token ID and secret cannot be changed by this method, but properties like name and description can.

      Specified by:
      updateToken in interface SecurityTokenService
      Parameters:
      token - the token details to update
    • deleteToken

      public void deleteToken(String tokenId)
      Description copied from interface: SecurityTokenService
      Delete a security token.

      No error is thrown if the given tokenId does not exist.

      Specified by:
      deleteToken in interface SecurityTokenService
      Parameters:
      tokenId - the ID of the token to delete