sprops

secure properties api

License

License

Categories

Categories

Ant Build Tools
GroupId

GroupId

com.github.antonsjava
ArtifactId

ArtifactId

sprops
Last Version

Last Version

1.1
Release Date

Release Date

Type

Type

jar
Description

Description

sprops
secure properties api
Project URL

Project URL

https://github.com/antonsjava/sprops
Source Code Management

Source Code Management

https://github.com/antonsjava/sprops

Download sprops

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.antonsjava/sprops/ -->
<dependency>
    <groupId>com.github.antonsjava</groupId>
    <artifactId>sprops</artifactId>
    <version>1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.antonsjava/sprops/
implementation 'com.github.antonsjava:sprops:1.1'
// https://jarcasting.com/artifacts/com.github.antonsjava/sprops/
implementation ("com.github.antonsjava:sprops:1.1")
'com.github.antonsjava:sprops:jar:1.1'
<dependency org="com.github.antonsjava" name="sprops" rev="1.1">
  <artifact name="sprops" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.antonsjava', module='sprops', version='1.1')
)
libraryDependencies += "com.github.antonsjava" % "sprops" % "1.1"
[com.github.antonsjava/sprops "1.1"]

Dependencies

compile (2)

Group / Artifact Type Version
com.github.antonsjava : jaul jar 1.5
com.github.antonsjava : slformatter jar 1.1

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

sprops

sprops is small library for encoding and decoding property files or simple string data.

Motivation for this project was to have possibility to store secret data like passwords together with sources or have it stored somewhere else publicly.

Property file with encoded properties are protected with one password. This must be provided 'secretly' but this one only.

sprops-tool

This is command line tool for manipulating the property files. Tool can be build by building this project.

Than you can use it for encoding and decoding properties in property file

Lets have simple property file like

  main.db.password=xxxx
  email.server.password=yyyy

than you can call

  /tmp/aaa> java -jar sprops-tool.jar -fencode passwords.properties  main.db.password
  INF   main command to execute FileEncodeCommand
  Enter password: 
  INF c.fenc Property: 'main.db.password'
  INF c.fenc Encoding string from: 'xxxx'
  INF c.fenc                   to: 'sprops:AAAAIBnzWe9H8rJtXVsOtBApsVC74BldooOGHOu4h1GJWuMpMpWXnD3b/vYurPjmHYM1Ww=='
  INF   main command FileEncodeCommand execution done.

and property looks like

  main.db.password=sprops:AAAAIBnzWe9H8rJtXVsOtBApsVC74BldooOGHOu4h1GJWuMpMpWXnD3b/vYurPjmHYM1Ww==
  email.server.password=yyyy

you can than call

  /tmp/aaa> java -jar sprops-tool.jar -fdecode passwords.properties  main.db.password
  INF   main command to execute FileDecodeCommand
  Enter password: 
  INF c.fdec Property: 'main.db.password'
  INF c.fdec Encoding string from: 'sprops:AAAAIBnzWe9H8rJtXVsOtBApsVC74BldooOGHOu4h1GJWuMpMpWXnD3b/vYurPjmHYM1Ww=='
  INF c.fdec                   to: 'xxxx'
  INF   main command FileDecodeCommand execution done.

and property looks like

  main.db.password=xxxx
  email.server.password=yyyy

There are also other options you can see it with --help option.

Property file usage

Encoded file can be used in application

  String password = .....
  Properties encodedProps = .....
  PropertiesEncoder encoder = PropertiesEncoder.instance(password);
  encoder.add(encodedProps);
  String decodedProperty = encoder.getProperty("property.name");
  Properties decodedProps = encoder.decode();

Simple encoding/decoding

You can use

  String password = .....
  String text = .....
  SimpleEncoder encoder = SimpleEncoder.instance(password);
  String encodedString = encoder.encode(text);
  String decodedString = encoder.decode(encodedString);

System properties utility

If you are using spring boot and you want to have encoded properties provide as SB property. An easy way is copy the properties to System properties at wery first moment of starting application

  Properties props = .....
  SystemPropertiesUpdater.instance(props)
    .map("main.db.password", "spring.datasource.password")
    .map("email.server.password", "myapp.notifier.password");

Maven usage

   <dependency>
      <groupId>com.github.antonsjava</groupId>
      <artifactId>sprops</artifactId>
      <version>1.1</version>
   </dependency>

Versions

Version
1.1