Class DataSigner

java.lang.Object
rs.baselib.crypto.DataSigner

public class DataSigner extends Object
The class for signing and verifying signatures.
Author:
ralph
  • Constructor Details

  • Method Details

    • getPrivateKey

      public PrivateKey getPrivateKey()
      Returns the privateKey.
      Returns:
      the privateKey
    • setPrivateKey

      public void setPrivateKey(PrivateKey privateKey)
      Sets the privateKey.
      Parameters:
      privateKey - the privateKey to set
    • setPrivateKey

      public void setPrivateKey(String privateKey) throws SigningException
      Sets the privateKey.
      Parameters:
      privateKey - the privateKey to set
      Throws:
      SigningException - - when a problem occurs
    • getPublicKey

      public PublicKey getPublicKey()
      Returns the publicKey.
      Returns:
      the publicKey
    • setPublicKey

      public void setPublicKey(PublicKey publicKey)
      Sets the publicKey.
      Parameters:
      publicKey - the publicKey to set
    • setPublicKey

      public void setPublicKey(String publicKey) throws SigningException
      Sets the publicKey.
      Parameters:
      publicKey - the publicKey to set
      Throws:
      SigningException - - when a problem occurs
    • sign

      public String sign(Reader reader) throws SigningException
      Creates a signature for the given stream.
      Parameters:
      reader - stream to be signed
      Returns:
      signature of the provided stream
      Throws:
      SigningException - - when a problem occurs
    • getByteSignature

      public byte[] getByteSignature(Reader reader) throws SigningException
      Creates a signature for the given stream.
      Parameters:
      reader - stream to be signed
      Returns:
      signature of the provided stream
      Throws:
      SigningException - - when a problem occurs
    • sign

      public String sign(InputStream in) throws SigningException
      Creates a signature for the given stream.
      Parameters:
      in - stream to be signed
      Returns:
      signature of the provided stream
      Throws:
      SigningException - - when a problem occurs
    • getByteSignature

      public byte[] getByteSignature(InputStream in) throws SigningException
      Creates a signature for the given stream.
      Parameters:
      in - stream to be signed
      Returns:
      signature of the provided stream
      Throws:
      SigningException - - when a problem occurs
    • update

      public void update(Signature signature, InputStream in) throws SigningException
      Updates the DSA with the bytes from this stream.
      Parameters:
      signature - signature
      in - input stream
      Throws:
      SigningException - when the stream cannot be signed
      SigningException - - when a problem occurs
    • update

      protected void update(Signature signature, Reader reader) throws SigningException
      Updates the DSA with the bytes from this stream.
      Parameters:
      signature - signature
      reader - reader for the input stream
      Throws:
      SigningException - when the signing process fails
    • sign

      public String sign(String str) throws SigningException
      Creates a signature for the given string.
      Parameters:
      str - string to be signed
      Returns:
      signature of the provided String
      Throws:
      SigningException - when the stream cannot be signed
    • getByteSignature

      public byte[] getByteSignature(String str) throws SigningException
      Creates a signature for the given string.
      Parameters:
      str - string to be signed
      Returns:
      signature of the provided String
      Throws:
      SigningException - when the stream cannot be signed
    • sign

      public String sign(byte[] bytes) throws SigningException
      Creates a signature for the given bytes.
      Parameters:
      bytes - bytes to be signed
      Returns:
      signature of the provided bytes
      Throws:
      SigningException - when the bytes cannot be signed
    • getByteSignature

      public byte[] getByteSignature(byte[] bytes) throws SigningException
      Creates a signature for the given bytes.
      Parameters:
      bytes - bytes to be signed
      Returns:
      signature of the provided bytes
      Throws:
      SigningException - when the bytes cannot be signed
    • verify

      public boolean verify(String signature, InputStream in) throws SigningException
      Verifies the signature on the given stream.
      Parameters:
      signature - signature
      in - stream to be verified
      Returns:
      true if the signature confirms stream integrity
      Throws:
      SigningException - when the signature cannot be verified
    • verify

      public boolean verify(byte[] signature, InputStream in) throws SigningException
      Verifies the signature on the given stream.
      Parameters:
      signature - signature
      in - stream to be verified
      Returns:
      true if the signature confirms stream integrity
      Throws:
      SigningException - when the signature cannot be verified
    • verify

      public boolean verify(String signature, Reader in) throws SigningException
      Verifies the signature on the given stream.
      Parameters:
      signature - signature
      in - stream to be verified
      Returns:
      true if the signature confirms stream integrity
      Throws:
      SigningException - when the signature cannot be verified
    • verify

      public boolean verify(byte[] signature, Reader in) throws SigningException
      Verifies the signature on the given stream.
      Parameters:
      signature - signature
      in - stream to be verified
      Returns:
      true if the signature confirms stream integrity
      Throws:
      SigningException - when the signature cannot be verified
    • verify

      public boolean verify(String signature, String str) throws SigningException
      Verifies the signature on the given string.
      Parameters:
      signature - signature
      str - string to be verified
      Returns:
      true if the signature confirms string integrity
      Throws:
      SigningException - when the signature cannot be verified
    • verify

      public boolean verify(byte[] signature, byte[] data) throws SigningException
      Verifies the signature on the given bytes.
      Parameters:
      signature - signature
      data - bytes to be verified
      Returns:
      true if the signature confirms data integrity
      Throws:
      SigningException - when the signature cannot be verified