Code Monkey home page Code Monkey logo

jackson-crypto's Introduction

Jackson Crypto

Build Status

Cryptographic utilities for Jackson.

Usage

To use this package from Maven, include the following dependency in your project:

<dependency>
  <groupId>com.meltmedia.jackson</groupId>
  <artifactId>jackson-crypto</artifactId>
  <version>0.2.0</version>
</dpendency>

Then create a new CryptoModule and register it with your ObjectMapper.

EncryptionService service = ...;
ObjectMapper mapper = ...;
mapper.registerModule(new CryptoModule().addSource(service));

Once this is done, you can use the @Encrypted annotation on your @JsonProperty annotated methods to encrypt them during serialization and decrypt them during deserialization. So, a POJO like the following:

public class Pojo {
  protected String secret;

  @JsonProperty
  @Encrypted
  public String getSecret() {
    return this.secret;
  }

  public void setSecret( String secret ) {
    this.secret = secret;
  }
}

will serialize into JSON like:

{
  "secret": {
    "salt": "tKD8wQ==",
    "iv": "s9hTJRaZn6fxxpA4nVfDag==",
    "value": "UZENJOltf+9EZS03AXbmeg==",
    "cipher": "aes-256-cbc",
    "keyDerivation": "pbkdf2",
    "keyLength": 256,
    "iterations": 2000
  }
}

Example

This project does not yet have its own example project, but you can see an example of using this library in the Dropwizard Crypto example project.

jackson-crypto's People

Contributors

ctrimble avatar

Stargazers

Patrick Cieplak avatar  avatar Domenico Giffone avatar Paul Tinius avatar Gabriel Ozeas de Oliveira avatar jzochowski avatar

Watchers

Martin Klose avatar  avatar James Cloos avatar

jackson-crypto's Issues

Not compatible with Jackson 2.7+ with lombok @AllArgsConstructor

I tested this code on Jackson 2.6 and it works pretty fine. However, when I migrated to 2.7 and 2.8, I found out that "deserialize" method in EncryptedJsonDeserializer class is never called, so that we got "Can not deserialize instance of java.lang.String out of START_OBJECT token" exception for a String type that we want to encrypt.

Provide CLI as example

There is currently no way to use this project without the dropwizard-crypto project. Add a CLI to the project that will encrypt/decrypt JSON.

High level requirements:

  • support encryption/decryption of nested JSON elements.
  • the CLI should not release to Maven Central
  • the CLI should be installed using brew

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.