Interface Server


public interface Server
A Server represents a network-based signature provider. The configuration for a NetProvider will generally define one or more Servers, and more may be found via Zeroconf
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    canSign(com.bfo.netkeystore.client.NetPrivateKey key, SignatureAlgorithm algorithm)
    Given a signature algorithm, return the hash algorithm that should be used to generate the digest for the signature for the specified key, or (if the key is null) if any key owned by this server could support that algorithm.
    void
    configure(String name, Json config, boolean auto)
    Configure the server
    Return the SignatureAlgorithm corresponding to the specified name, or null if none exists
    void
    Load the keystore from the Core with keys
    void
    Login to the server.
    void
    Log out of the server.
    boolean
    shutdown(boolean auto)
    Shut down the server and prepare it for removal from the KeyStore.
    byte[]
    sign(com.bfo.netkeystore.client.NetPrivateKey key, SignatureAlgorithm algorithm, AlgorithmParameters params, byte[] data)
    This calls "credentials/authorize" then "signature/hash"
  • Method Details

    • configure

      void configure(String name, Json config, boolean auto) throws Exception
      Configure the server
      Parameters:
      name - the server name
      config - the configuration
      auto - if true, the server has been auto-configured from Zeroconf
      Throws:
      Exception - if the server failed to configure
    • login

      void login(Subject subject, KeyStore.ProtectionParameter prot) throws IOException
      Login to the server. Called from AuthProvider.login(javax.security.auth.Subject, javax.security.auth.callback.CallbackHandler), or the first time a key is requested from its keystore
      Parameters:
      subject - the subject, or null
      prot - the ProtectionParameter used to load the keystore
      Throws:
      IOException - for IOException
    • logout

      void logout() throws IOException
      Log out of the server. Called from AuthProvider.logout()
      Throws:
      IOException - for IOException
    • shutdown

      boolean shutdown(boolean auto) throws IOException
      Shut down the server and prepare it for removal from the KeyStore. Only currently used for Zeroconf-originating servers when they go offline
      Parameters:
      auto - if true, shut the server down only if it was configured with auto=true
      Returns:
      true if the server was shutdown, false if the request was ignored.
      Throws:
      IOException - for IOException
    • getSignatureAlgorithm

      SignatureAlgorithm getSignatureAlgorithm(String name)
      Return the SignatureAlgorithm corresponding to the specified name, or null if none exists
      Parameters:
      name - the signature name, eg "SHA256withRSA"
      Returns:
      the SignatureAlgorithm
    • load

      void load() throws IOException
      Load the keystore from the Core with keys
      Throws:
      IOException - for IOException
    • sign

      byte[] sign(com.bfo.netkeystore.client.NetPrivateKey key, SignatureAlgorithm algorithm, AlgorithmParameters params, byte[] data) throws UnrecoverableKeyException, IOException
      This calls "credentials/authorize" then "signature/hash"
      Parameters:
      key - the signing key
      algorithm - the signature algorithm
      params - the signature algorithm params (normally null)
      data - the digest to sign
      Returns:
      the signature bytes
      Throws:
      IOException - for IOException
      UnrecoverableKeyException - if the key can't be unlocked
    • canSign

      void canSign(com.bfo.netkeystore.client.NetPrivateKey key, SignatureAlgorithm algorithm) throws InvalidKeyException
      Given a signature algorithm, return the hash algorithm that should be used to generate the digest for the signature for the specified key, or (if the key is null) if any key owned by this server could support that algorithm.
      Parameters:
      key - the key that will be used for the signature, or null to check if any key supported by this Server supports the algorithm
      algorithm - the signature algorithm as requested by the client
      Throws:
      InvalidKeyException - if the key cannot be used