Class AbstractGeneratorHostKeyProvider

    • Field Detail

      • DEFAULT_ALGORITHM

        public static final java.lang.String DEFAULT_ALGORITHM
        See Also:
        Constant Field Values
      • DEFAULT_ALLOWED_TO_OVERWRITE

        public static final boolean DEFAULT_ALLOWED_TO_OVERWRITE
        See Also:
        Constant Field Values
      • keyPairHolder

        private final java.util.concurrent.atomic.AtomicReference<java.lang.Iterable<java.security.KeyPair>> keyPairHolder
      • path

        private java.nio.file.Path path
      • algorithm

        private java.lang.String algorithm
      • keySize

        private int keySize
      • keySpec

        private java.security.spec.AlgorithmParameterSpec keySpec
      • overwriteAllowed

        private boolean overwriteAllowed
    • Constructor Detail

      • AbstractGeneratorHostKeyProvider

        protected AbstractGeneratorHostKeyProvider()
    • Method Detail

      • getPath

        public java.nio.file.Path getPath()
      • setPath

        public void setPath​(java.nio.file.Path path)
      • setAlgorithm

        public void setAlgorithm​(java.lang.String algorithm)
      • getKeySize

        public int getKeySize()
        Specified by:
        getKeySize in interface KeySizeIndicator
        Returns:
        The number of bits used in the key
      • setKeySize

        public void setKeySize​(int keySize)
      • getKeySpec

        public java.security.spec.AlgorithmParameterSpec getKeySpec()
      • setKeySpec

        public void setKeySpec​(java.security.spec.AlgorithmParameterSpec keySpec)
      • isOverwriteAllowed

        public boolean isOverwriteAllowed()
      • setOverwriteAllowed

        public void setOverwriteAllowed​(boolean overwriteAllowed)
      • clearLoadedKeys

        public void clearLoadedKeys()
      • loadKeys

        public java.util.List<java.security.KeyPair> loadKeys​(SessionContext session)
        Description copied from interface: KeyIdentityProvider
        Load available keys.
        Specified by:
        loadKeys in interface KeyIdentityProvider
        Parameters:
        session - The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
        Returns:
        an Iterable instance of available keys - ignored if null
      • resolveKeyPairs

        protected java.lang.Iterable<java.security.KeyPair> resolveKeyPairs​(SessionContext session,
                                                                            java.nio.file.Path keyPath)
                                                                     throws java.io.IOException,
                                                                            java.security.GeneralSecurityException
        Throws:
        java.io.IOException
        java.security.GeneralSecurityException
      • loadFromFile

        protected java.lang.Iterable<java.security.KeyPair> loadFromFile​(SessionContext session,
                                                                         java.lang.String alg,
                                                                         java.nio.file.Path keyPath)
                                                                  throws java.io.IOException,
                                                                         java.security.GeneralSecurityException
        Throws:
        java.io.IOException
        java.security.GeneralSecurityException
      • readKeyPairs

        protected java.lang.Iterable<java.security.KeyPair> readKeyPairs​(SessionContext session,
                                                                         java.nio.file.Path keyPath,
                                                                         java.nio.file.OpenOption... options)
                                                                  throws java.io.IOException,
                                                                         java.security.GeneralSecurityException
        Throws:
        java.io.IOException
        java.security.GeneralSecurityException
      • doReadKeyPairs

        protected java.lang.Iterable<java.security.KeyPair> doReadKeyPairs​(SessionContext session,
                                                                           NamedResource resourceKey,
                                                                           java.io.InputStream inputStream)
                                                                    throws java.io.IOException,
                                                                           java.security.GeneralSecurityException
        Throws:
        java.io.IOException
        java.security.GeneralSecurityException
      • writeKeyPair

        protected void writeKeyPair​(java.security.KeyPair kp,
                                    java.nio.file.Path keyPath)
                             throws java.io.IOException,
                                    java.security.GeneralSecurityException
        Throws:
        java.io.IOException
        java.security.GeneralSecurityException
      • setFilePermissions

        private void setFilePermissions​(java.nio.file.Path path)
                                 throws java.io.IOException
        Throws:
        java.io.IOException
      • doWriteKeyPair

        protected abstract void doWriteKeyPair​(NamedResource resourceKey,
                                               java.security.KeyPair kp,
                                               java.io.OutputStream outputStream)
                                        throws java.io.IOException,
                                               java.security.GeneralSecurityException
        Throws:
        java.io.IOException
        java.security.GeneralSecurityException
      • generateKeyPair

        protected java.security.KeyPair generateKeyPair​(java.lang.String algorithm)
                                                 throws java.security.GeneralSecurityException
        Throws:
        java.security.GeneralSecurityException