content: package com.bol.system;
  
  import com.bol.crypt.CryptVault;
  import com.mongodb.ConnectionString;
  import com.mongodb.MongoClientSettings;
  import com.mongodb.client.MongoClient;
  import com.mongodb.client.MongoClients;
  import org.bson.UuidRepresentation;
  import org.springframework.beans.factory.annotation.Value;
  import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.data.mongodb.MongoDatabaseFactory;
  import org.springframework.data.mongodb.config.AbstractMongoClientConfiguration;
  import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
  import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
  import org.springframework.data.mongodb.core.convert.MongoCustomConversions;
  import org.springframework.data.mongodb.core.mapping.MongoMappingContext;
  
  import java.util.Base64;
  
  @Configuration
  public abstract class MongoDBConfiguration extends AbstractMongoClientConfiguration {
  
      private static final byte[] secretKey = Base64.getDecoder().decode("hqHKBLV83LpCqzKpf8OvutbCs+O5wX5BPu3btWpEvXA=");
  
      @Value("${mongodb.port:27017}")
      int port;
  
      @Override
      protected String getDatabaseName() {
          return "test";
      }
  
      @Override
      public MongoClient mongoClient() {
          return MongoClients.create(MongoClientSettings.builder()
                  .uuidRepresentation(UuidRepresentation.STANDARD)
                  .applyConnectionString(new ConnectionString("mongodb://localhost:" + port))
                  .build()
          );
      }
  
      @Bean
      public CryptVault cryptVault() {
          return new CryptVault()
                  .with256BitAesCbcPkcs5PaddingAnd128BitSaltKey(0, secretKey)
                  .withDefaultKeyVersion(0);
      }
  }
  