class SymmetricKeyCryptographyService extends ServiceImp {

  @Override
  public void doService(AdaptrisMessage msg) throws ServiceException {
    try {
      String algToUse = msg.resolve(getAlgorithm());
      String cipherToUse = msg.resolve(getCipherTransformation());
      byte[] keyBytes = Conversion.base64StringToByteArray(
          Password.decode(ExternalResolver.resolve(getKey().extract(msg))));
      byte[] initialVectorBytes =  Conversion.base64StringToByteArray(getInitialVector().extract(msg));
      Cipher cipher = Cipher.getInstance(cipherToUse);
      SecretKeySpec secretKeySpec = new SecretKeySpec(keyBytes, algToUse);
      IvParameterSpec ivParameterSpec = new IvParameterSpec(initialVectorBytes);
      getOperationMode().execute(cipher, secretKeySpec, ivParameterSpec, source().wrap(msg),
          target().wrap(msg));
    } catch (Exception e) {
      throw ExceptionHelper.wrapServiceException(e);
    }
  }

  public  SymmetricKeyCryptographyService();

}