Map < Key < EncryptionService > , EncryptionService > createBindings ( CryptoConfig cryptoConfig , List < KeyPairConfig > keyPairConfigurations , Map < String , KeyStore > keyStores ) { Map < Key < EncryptionService > , EncryptionService > encryptionServices = new HashMap <> ( ) ; Map < String , EncryptionServiceFactory > encryptionServiceFactories = new HashMap <> ( ) ; if ( keyPairConfigurations != null && keyStores != null ) { for ( KeyPairConfig keyPairConfig : keyPairConfigurations ) { String keyStoreName = keyPairConfig . getKeyStoreName ( ) ; if ( ! encryptionServiceFactories . containsKey ( keyStoreName ) ) { EncryptionServiceFactory factory = new EncryptionServiceFactory ( cryptoConfig , keyStores . get ( keyStoreName ) ) ; encryptionServiceFactories . put ( keyStoreName , factory ) ; } EncryptionServiceFactory serviceFactory = encryptionServiceFactories . get ( keyStoreName ) ; EncryptionService encryptionService ; if ( keyPairConfig . getPassword ( ) != null ) { encryptionService = serviceFactory . create ( keyPairConfig . getAlias ( ) , keyPairConfig . getPassword ( ) . toCharArray ( ) ) ; } else { encryptionService = serviceFactory . create ( keyPairConfig . getAlias ( ) ) ; } if ( keyPairConfig . getQualifier ( ) != null ) { encryptionServices . put ( createKeyFromQualifier ( keyPairConfig . getQualifier ( ) ) , encryptionService ) ; } else { encryptionServices . put ( Key . get ( EncryptionService . class , Names . named ( keyPairConfig . getAlias ( ) ) ) , encryptionService ) ; } } } return encryptionServices ; }
Creates the encryption service bindings .