Search in sources :

Example 1 with EncryptionModule

use of com.couchbase.client.java.encryption.databind.jackson.EncryptionModule in project spring-data-couchbase by spring-projects.

the class AbstractCouchbaseConfiguration method couchbaseObjectMapper.

/**
 * Creates a {@link ObjectMapper} for the jsonSerializer of the ClusterEnvironment
 *
 * @return ObjectMapper
 */
public ObjectMapper couchbaseObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.registerModule(new JsonValueModule());
    CryptoManager cryptoManager = null;
    if (cryptoManager != null) {
        mapper.registerModule(new EncryptionModule(cryptoManager));
    }
    return mapper;
}
Also used : CryptoManager(com.couchbase.client.core.encryption.CryptoManager) EncryptionModule(com.couchbase.client.java.encryption.databind.jackson.EncryptionModule) JsonValueModule(com.couchbase.client.java.json.JsonValueModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with EncryptionModule

use of com.couchbase.client.java.encryption.databind.jackson.EncryptionModule in project couchbase-jvm-clients by couchbase.

the class JacksonJsonSerializer method create.

/**
 * Returns a new instance backed by a default ObjectMapper
 * with optional encryption support.
 *
 * @param cryptoManager (nullable) The manager to use for activating the
 * {@link Encrypted} annotation, or null to disable encryption support.
 *   @return the Jackson JSON serializer with a provided crypto manager.
 */
public static JacksonJsonSerializer create(CryptoManager cryptoManager) {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JsonValueModule());
    if (cryptoManager != null) {
        mapper.registerModule(new EncryptionModule(cryptoManager));
    }
    return new JacksonJsonSerializer(mapper);
}
Also used : EncryptionModule(com.couchbase.client.java.encryption.databind.jackson.EncryptionModule) JsonValueModule(com.couchbase.client.java.json.JsonValueModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

EncryptionModule (com.couchbase.client.java.encryption.databind.jackson.EncryptionModule)2 JsonValueModule (com.couchbase.client.java.json.JsonValueModule)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 CryptoManager (com.couchbase.client.core.encryption.CryptoManager)1