Class OpenSSHCertificateDecoder

    • Constructor Detail

      • OpenSSHCertificateDecoder

        public OpenSSHCertificateDecoder()
    • Method Detail

      • decodePublicKey

        public OpenSshCertificate decodePublicKey​(SessionContext session,
                                                  java.lang.String keyType,
                                                  java.io.InputStream keyData,
                                                  java.util.Map<java.lang.String,​java.lang.String> headers)
                                           throws java.io.IOException,
                                                  java.security.GeneralSecurityException
        Parameters:
        session - The SessionContext for invoking this command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
        keyType - The reported / encode key type
        keyData - The key data bytes stream positioned after the key type decoding and making sure it is one of the supported types
        headers - Any headers that may have been available when data was read
        Returns:
        The decoded PublicKey
        Throws:
        java.io.IOException - If failed to read from the data stream
        java.security.GeneralSecurityException - If failed to generate the key
      • encodePublicKey

        public java.lang.String encodePublicKey​(java.io.OutputStream s,
                                                OpenSshCertificate key)
                                         throws java.io.IOException
        Description copied from interface: PublicKeyEntryDecoder
        Encodes the PublicKey using the OpenSSH format - same one used by the decodePublicKey method(s)
        Parameters:
        s - The OutputStream to write the data to
        key - The PublicKey - may not be null
        Returns:
        The key type value - one of the KeyTypeNamesSupport.getSupportedKeyTypes()
        Throws:
        java.io.IOException - If failed to generate the encoding
      • clonePublicKey

        public OpenSshCertificate clonePublicKey​(OpenSshCertificate 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

        public OpenSshCertificate clonePrivateKey​(OpenSshCertificate 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

        public 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

        public 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