Interface KeyEntryResolver<PUB extends java.security.PublicKey,​PRV extends java.security.PrivateKey>

    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      default java.security.KeyPair cloneKeyPair​(java.security.KeyPair kp)  
      PRV clonePrivateKey​(PRV key)  
      PUB clonePublicKey​(PUB key)  
      static java.math.BigInteger decodeBigInt​(java.io.InputStream s)  
      static int decodeInt​(byte[] buf)  
      static int decodeInt​(byte[] buf, int offset, int available)  
      static int decodeInt​(java.io.InputStream s)  
      static java.util.Map.Entry<java.lang.String,​java.lang.Integer> decodeString​(byte[] buf, int maxChars)  
      static java.util.Map.Entry<java.lang.String,​java.lang.Integer> decodeString​(byte[] buf, int offset, int available, int maxChars)  
      static java.util.Map.Entry<java.lang.String,​java.lang.Integer> decodeString​(byte[] buf, int offset, int available, java.nio.charset.Charset cs, int maxChars)
      Decodes a run-length encoded string
      static java.util.Map.Entry<java.lang.String,​java.lang.Integer> decodeString​(byte[] buf, java.nio.charset.Charset cs, int maxChars)  
      static java.lang.String decodeString​(java.io.InputStream s, int maxChars)  
      static java.lang.String decodeString​(java.io.InputStream s, java.lang.String charset, int maxChars)  
      static java.lang.String decodeString​(java.io.InputStream s, java.nio.charset.Charset cs, int maxChars)  
      static int encodeBigInt​(java.io.OutputStream s, java.math.BigInteger v)  
      static byte[] encodeInt​(java.io.OutputStream s, int v)  
      static int encodeString​(java.io.OutputStream s, java.lang.String v)  
      static int encodeString​(java.io.OutputStream s, java.lang.String v, java.lang.String charset)  
      static int encodeString​(java.io.OutputStream s, java.lang.String v, java.nio.charset.Charset cs)  
      default java.security.KeyPair generateKeyPair​(int keySize)  
      java.security.KeyFactory getKeyFactoryInstance()  
      java.security.KeyPairGenerator getKeyPairGenerator()  
      static java.util.Map.Entry<byte[],​java.lang.Integer> readRLEBytes​(byte[] buf, int maxAllowed)  
      static java.util.Map.Entry<byte[],​java.lang.Integer> readRLEBytes​(byte[] buf, int offset, int available, int maxAllowed)
      Decodes a run-length encoded byte array
      static byte[] readRLEBytes​(java.io.InputStream s, int maxAllowed)  
      static int writeRLEBytes​(java.io.OutputStream s, byte... bytes)  
      static int writeRLEBytes​(java.io.OutputStream s, byte[] bytes, int off, int len)  
    • Method Detail

      • generateKeyPair

        default java.security.KeyPair generateKeyPair​(int keySize)
                                               throws java.security.GeneralSecurityException
        Parameters:
        keySize - Key size in bits
        Returns:
        A KeyPair with the specified key size
        Throws:
        java.security.GeneralSecurityException - if unable to generate the pair
      • cloneKeyPair

        default java.security.KeyPair cloneKeyPair​(java.security.KeyPair kp)
                                            throws java.security.GeneralSecurityException
        Parameters:
        kp - The KeyPair to be cloned - ignored if null
        Returns:
        A cloned pair (or null if no original pair)
        Throws:
        java.security.GeneralSecurityException - If failed to clone - e.g., provided key pair does not contain keys of the expected type
        See Also:
        IdentityResourceLoader.getPublicKeyType(), IdentityResourceLoader.getPrivateKeyType()
      • clonePublicKey

        PUB clonePublicKey​(PUB key)
                    throws java.security.GeneralSecurityException
        Parameters:
        key - The PublicKey to clone - ignored if null
        Returns:
        The cloned key (or null if no original key)
        Throws:
        java.security.GeneralSecurityException - If failed to clone the key
      • clonePrivateKey

        PRV clonePrivateKey​(PRV key)
                     throws java.security.GeneralSecurityException
        Parameters:
        key - The PrivateKey to clone - ignored if null
        Returns:
        The cloned key (or null if no original key)
        Throws:
        java.security.GeneralSecurityException - If failed to clone the key
      • getKeyPairGenerator

        java.security.KeyPairGenerator getKeyPairGenerator()
                                                    throws java.security.GeneralSecurityException
        Returns:
        A KeyPairGenerator suitable for this decoder
        Throws:
        java.security.GeneralSecurityException - If failed to create the generator
      • getKeyFactoryInstance

        java.security.KeyFactory getKeyFactoryInstance()
                                                throws java.security.GeneralSecurityException
        Returns:
        A KeyFactory suitable for the specific decoder type
        Throws:
        java.security.GeneralSecurityException - If failed to create one
      • encodeString

        static int encodeString​(java.io.OutputStream s,
                                java.lang.String v)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • encodeString

        static int encodeString​(java.io.OutputStream s,
                                java.lang.String v,
                                java.lang.String charset)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • encodeString

        static int encodeString​(java.io.OutputStream s,
                                java.lang.String v,
                                java.nio.charset.Charset cs)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • encodeBigInt

        static int encodeBigInt​(java.io.OutputStream s,
                                java.math.BigInteger v)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • writeRLEBytes

        static int writeRLEBytes​(java.io.OutputStream s,
                                 byte... bytes)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • writeRLEBytes

        static int writeRLEBytes​(java.io.OutputStream s,
                                 byte[] bytes,
                                 int off,
                                 int len)
                          throws java.io.IOException
        Throws:
        java.io.IOException
      • encodeInt

        static byte[] encodeInt​(java.io.OutputStream s,
                                int v)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • decodeString

        static java.lang.String decodeString​(java.io.InputStream s,
                                             int maxChars)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • decodeString

        static java.lang.String decodeString​(java.io.InputStream s,
                                             java.lang.String charset,
                                             int maxChars)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • decodeString

        static java.lang.String decodeString​(java.io.InputStream s,
                                             java.nio.charset.Charset cs,
                                             int maxChars)
                                      throws java.io.IOException
        Throws:
        java.io.IOException
      • decodeBigInt

        static java.math.BigInteger decodeBigInt​(java.io.InputStream s)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • readRLEBytes

        static byte[] readRLEBytes​(java.io.InputStream s,
                                   int maxAllowed)
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • decodeInt

        static int decodeInt​(java.io.InputStream s)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • decodeString

        static java.util.Map.Entry<java.lang.String,​java.lang.Integer> decodeString​(byte[] buf,
                                                                                          int maxChars)
      • decodeString

        static java.util.Map.Entry<java.lang.String,​java.lang.Integer> decodeString​(byte[] buf,
                                                                                          int offset,
                                                                                          int available,
                                                                                          int maxChars)
      • decodeString

        static java.util.Map.Entry<java.lang.String,​java.lang.Integer> decodeString​(byte[] buf,
                                                                                          java.nio.charset.Charset cs,
                                                                                          int maxChars)
      • decodeString

        static java.util.Map.Entry<java.lang.String,​java.lang.Integer> decodeString​(byte[] buf,
                                                                                          int offset,
                                                                                          int available,
                                                                                          java.nio.charset.Charset cs,
                                                                                          int maxChars)
        Decodes a run-length encoded string
        Parameters:
        buf - The buffer with the data bytes
        offset - The offset in the buffer to decode the string
        available - The max. available data starting from the offset
        cs - The Charset to use to decode the string
        maxChars - Max. allowed characters in string - if more than that is encoded then an IndexOutOfBoundsException will be thrown
        Returns:
        The decoded string + the offset of the next byte after it
        See Also:
        readRLEBytes(byte[], int, int, int)
      • readRLEBytes

        static java.util.Map.Entry<byte[],​java.lang.Integer> readRLEBytes​(byte[] buf,
                                                                                int maxAllowed)
      • readRLEBytes

        static java.util.Map.Entry<byte[],​java.lang.Integer> readRLEBytes​(byte[] buf,
                                                                                int offset,
                                                                                int available,
                                                                                int maxAllowed)
        Decodes a run-length encoded byte array
        Parameters:
        buf - The buffer with the data bytes
        offset - The offset in the buffer to decode the array
        available - The max. available data starting from the offset
        maxAllowed - Max. allowed data in decoded buffer - if more than that is encoded then an IndexOutOfBoundsException will be thrown
        Returns:
        The decoded data buffer + the offset of the next byte after it
      • decodeInt

        static int decodeInt​(byte[] buf)
      • decodeInt

        static int decodeInt​(byte[] buf,
                             int offset,
                             int available)