Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

automatic generation of CryptotulsService classes to reduce boilerplate code

License

Notifications You must be signed in to change notification settings

HoneyedOakTechnologies/ppksecuredws-crypto-util

Repository files navigation

ppksecuredws-crypto-util

automatic generation of CryptoService classes to reduce boilerplate.

provided annotations

@AsymmetricCryptoService(serviceName = "AsymmetricCryptoService", algorithm = "rsa", keysize = 4096) //all params are optional, shown values are provided defaults
@SymmetricCryptoService(serviceName = "SymmetricCryptoService", algorithm = "PBEWITHSHA256AND128BITAES-CBC-BC") //all params are optional, shown values are provided defaults

Both are meant to set on package level where they will generate their respective @Services, each implementing com.honeyedoak.cryptoutils.AsymmetricCryptoUtils or com.honeyedoak.cryptoutils.SymmetricCryptoUtils interfaces.

AsymmetricCryptoService

example of generated class:

package com.honeyedoak.cryptoutils.test.service;

import com.honeyedoak.cryptoutils.AsymmetricCryptoUtils;
import com.honeyedoak.cryptoutils.AsymmetricCryptoUtilsImpl;
import com.honeyedoak.cryptoutils.exception.CryptoException;
import java.lang.Override;
import java.security.Key;
import java.security.KeyPair;
import java.security.PrivateKey;
import java.security.PublicKey;
import org.springframework.stereotype.Service;

@Service
public class AsymmetricCryptoService implements com.honeyedoak.cryptoutils.AsymmetricCryptoService {
  private final AsymmetricCryptoUtils asymmetricCryptoUtils;

  AsymmetricCryptoService() {
    this.asymmetricCryptoUtils = new AsymmetricCryptoUtilsImpl("RSA", 4096);}

  @Override
  public KeyPair generateKeyPair() throws CryptoException {
    return this.asymmetricCryptoUtils.generateKeyPair();}

  @Override
  public PrivateKey decodePrivateKey(byte[] encodedKey) throws CryptoException {
    return asymmetricCryptoUtils.decodePrivateKey(encodedKey);}

  @Override
  public PublicKey decodePublicKey(byte[] encodedKey) throws CryptoException {
    return asymmetricCryptoUtils.decodePublicKey(encodedKey);}

  @Override
  public byte[] decrypt(byte[] payload, Key key) throws CryptoException {
    return asymmetricCryptoUtils.decrypt(payload, key);}

  @Override
  public byte[] encrypt(byte[] payload, Key key) throws CryptoException {
    return asymmetricCryptoUtils.encrypt(payload, key);}
}

SymmetricCryptoService

example of generated class:

package com.honeyedoak.cryptoutils.test.service;

import com.honeyedoak.cryptoutils.SymmetricCryptoUtils;
import com.honeyedoak.cryptoutils.SymmetricCryptoUtilsImpl;
import java.lang.Override;
import java.lang.String;
import org.springframework.stereotype.Service;

@Service
public class SymmetricCryptoService implements com.honeyedoak.cryptoutils.SymmetricCryptoService {
  private final SymmetricCryptoUtils symmetricCryptoUtils;

  SymmetricCryptoService() {
    this.symmetricCryptoUtils = new SymmetricCryptoUtilsImpl("PBEWITHSHA256AND128BITAES-CBC-BC");}

  @Override
  public byte[] decrypt(byte[] payload, String password) {
    return symmetricCryptoUtils.decrypt(payload, password);}

  @Override
  public byte[] decrypt(byte[] payload, char[] password) {
    return symmetricCryptoUtils.decrypt(payload, password);}

  @Override
  public byte[] encrypt(byte[] payload, String password) {
    return symmetricCryptoUtils.encrypt(payload, password);}

  @Override
  public byte[] encrypt(byte[] payload, char[] password) {
    return symmetricCryptoUtils.encrypt(payload, password);}
}

About

automatic generation of CryptotulsService classes to reduce boilerplate code

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages