Class SecretKeyService


  • @Named
    @Singleton
    public class SecretKeyService
    extends java.lang.Object
    Service for secret key operations using Java KeyStore API.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static org.slf4j.Logger log  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void generateSecretKey​(java.io.File keystore, java.lang.String storetype, java.lang.String storepass, java.lang.String alias, java.lang.String keyalg, java.lang.String keysize, java.lang.String keypass)
      Generates a secret key and stores it in the keystore.
      private java.security.KeyStore loadOrCreateKeyStore​(java.io.File keystoreFile, java.lang.String storeType, char[] storePassword)
      Loads an existing keystore or creates a new one.
      private void saveKeyStore​(java.security.KeyStore ks, java.io.File keystoreFile, char[] storePassword)
      Saves the keystore to file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • log

        private static final org.slf4j.Logger log
    • Constructor Detail

      • SecretKeyService

        public SecretKeyService()
    • Method Detail

      • generateSecretKey

        public void generateSecretKey​(java.io.File keystore,
                                      java.lang.String storetype,
                                      java.lang.String storepass,
                                      java.lang.String alias,
                                      java.lang.String keyalg,
                                      java.lang.String keysize,
                                      java.lang.String keypass)
                               throws org.apache.maven.plugin.MojoExecutionException
        Generates a secret key and stores it in the keystore.
        Parameters:
        keystore - keystore location
        storetype - keystore type (defaults to KeyStore.getDefaultType() if null)
        storepass - keystore password
        alias - key alias
        keyalg - key algorithm (e.g., "AES", "DES", "DESede")
        keysize - key size in bits (e.g., "128", "256")
        keypass - key password (defaults to storepass if null)
        Throws:
        org.apache.maven.plugin.MojoExecutionException - if operation fails
      • loadOrCreateKeyStore

        private java.security.KeyStore loadOrCreateKeyStore​(java.io.File keystoreFile,
                                                            java.lang.String storeType,
                                                            char[] storePassword)
                                                     throws java.lang.Exception
        Loads an existing keystore or creates a new one.
        Throws:
        java.lang.Exception
      • saveKeyStore

        private void saveKeyStore​(java.security.KeyStore ks,
                                  java.io.File keystoreFile,
                                  char[] storePassword)
                           throws java.lang.Exception
        Saves the keystore to file.
        Throws:
        java.lang.Exception