Refactored project: split library and command line binary into separate module.
This commit is contained in:
@@ -10,3 +10,5 @@
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
target/
|
||||
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>rs.in.zivanovic</groupId>
|
||||
<artifactId>j-password-obfuscator-bin</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>JPasswordObfuscator binary</name>
|
||||
<description>
|
||||
Java command line interface for sensitive data obfuscation and de-obfuscation.
|
||||
Solution for protecting passwords and other sensitive data in configuration files or in transit from casual glances.
|
||||
Not at all useful for protecting sensitive data from attackers bent on stealing your secrets.
|
||||
</description>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>MIT license</name>
|
||||
<url>http://opensource.org/licenses/MIT</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>marko</id>
|
||||
<name>Marko Zivanovic</name>
|
||||
<email>marko@zivanovic.in.rs</email>
|
||||
<url>http://marko.zivanovic.in.rs</url>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
<timezone>+1</timezone>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<organization>
|
||||
<name>Marko Zivanovic</name>
|
||||
<url>http://marko.zivanovic.in.rs</url>
|
||||
</organization>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.beust</groupId>
|
||||
<artifactId>jcommander</artifactId>
|
||||
<version>1.47</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>18.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>j-password-obfuscator</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>appassembler-maven-plugin</artifactId>
|
||||
<version>1.9</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>assemble</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<binFileExtensions>
|
||||
<unix>.sh</unix>
|
||||
</binFileExtensions>
|
||||
<repositoryLayout>flat</repositoryLayout>
|
||||
<repositoryName>lib</repositoryName>
|
||||
<useWildcardClassPath>true</useWildcardClassPath>
|
||||
<licenseHeaderFile>../LICENSE</licenseHeaderFile>
|
||||
<programs>
|
||||
<program>
|
||||
<platforms>
|
||||
<platform>unix</platform>
|
||||
<platform>windows</platform>
|
||||
</platforms>
|
||||
<mainClass>rs.in.zivanovic.obfuscator.Main</mainClass>
|
||||
<id>jPasswordObfuscator</id>
|
||||
</program>
|
||||
</programs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<descriptor>src/main/assembly/bin.xml</descriptor>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
|
||||
http://maven.apache.org/xsd/assembly-1.1.2.xsd">
|
||||
|
||||
<id>bin</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>target/appassembler/lib</directory>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<excludes>
|
||||
<exclude>maven-metadata-appassembler.xml</exclude>
|
||||
</excludes>
|
||||
</fileSet>
|
||||
<fileSet>
|
||||
<directory>target/appassembler/bin</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<fileMode>0755</fileMode>
|
||||
<lineEnding>unix</lineEnding>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2015 Marko Zivanovic.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package rs.in.zivanovic.obfuscator;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.google.common.base.Joiner;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of the obfuscate command.
|
||||
*
|
||||
* @author Marko Zivanovic <marko@zivanovic.in.rs>
|
||||
*/
|
||||
@Parameters(commandDescription = "De-obfuscate sensitive data")
|
||||
public class DeObfuscateCommand implements Runnable {
|
||||
|
||||
@Parameter(names = {"-k", "--key"}, description = "Master key to use for de-obfuscation", required = true)
|
||||
private String masterKey;
|
||||
|
||||
@Parameter(description = "obfuscated string to de-obfuscate", required = true)
|
||||
private List<String> data;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JPasswordObfuscator jpo = new JPasswordObfuscator();
|
||||
String obfuscated = Joiner.on(' ').skipNulls().join(data);
|
||||
byte[] deObfuscated = jpo.deObfuscate(masterKey.toCharArray(), obfuscated);
|
||||
System.out.println(new String(deObfuscated, StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2015 Marko Zivanovic.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package rs.in.zivanovic.obfuscator;
|
||||
|
||||
import com.beust.jcommander.JCommander;
|
||||
import com.beust.jcommander.ParameterException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Main entry point.
|
||||
*
|
||||
* @author Marko Zivanovic <marko@zivanovic.in.rs>
|
||||
*/
|
||||
public class Main {
|
||||
|
||||
public static void main(String args[]) {
|
||||
JCommander jc = new JCommander();
|
||||
Map<String, Runnable> commands = new HashMap<>();
|
||||
Map<String, String[]> aliases = new HashMap<>();
|
||||
commands.put("o", new ObfuscateCommand());
|
||||
aliases.put("o", new String[]{"ob", "obfuscate"});
|
||||
commands.put("d", new DeObfuscateCommand());
|
||||
aliases.put("d", new String[]{"deob", "deobfuscate"});
|
||||
for (Entry<String, Runnable> e : commands.entrySet()) {
|
||||
String[] a = aliases.get(e.getKey());
|
||||
jc.addCommand(e.getKey(), e.getValue(), a);
|
||||
}
|
||||
|
||||
try {
|
||||
jc.parse(args);
|
||||
if (commands.keySet().contains(jc.getParsedCommand())) {
|
||||
Runnable r = commands.get(jc.getParsedCommand());
|
||||
r.run();
|
||||
} else {
|
||||
jc.usage();
|
||||
}
|
||||
} catch (RuntimeException ex) {
|
||||
System.err.println(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2015 Marko Zivanovic.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package rs.in.zivanovic.obfuscator;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
import com.google.common.base.Joiner;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of the obfuscate command.
|
||||
*
|
||||
* @author Marko Zivanovic <marko@zivanovic.in.rs>
|
||||
*/
|
||||
@Parameters(commandDescription = "Obfuscate sensitive data")
|
||||
public class ObfuscateCommand implements Runnable {
|
||||
|
||||
@Parameter(names = {"-k", "--key"}, description = "Master key to use for obfuscation", required = true)
|
||||
private String masterKey;
|
||||
|
||||
@Parameter(names = {"-v", "--version"}, description = "Version of the algorithm to use", required = false)
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
private int version = 1;
|
||||
|
||||
@Parameter(description = "data to obfuscate", required = true)
|
||||
private List<String> data;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
JPasswordObfuscator jpo = new JPasswordObfuscator();
|
||||
byte[] dataBytes = Joiner.on(' ').join(data).getBytes(StandardCharsets.UTF_8);
|
||||
String s = jpo.obfuscate(masterKey.toCharArray(), dataBytes, version);
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>rs.in.zivanovic</groupId>
|
||||
<artifactId>j-password-obfuscator</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>JPasswordObfuscator library</name>
|
||||
<description>
|
||||
Extensible Java library for sensitive data obfuscation and de-obfuscation.
|
||||
Solution for protecting passwords and other sensitive data in configuration files or in transit from casual glances.
|
||||
Not at all useful for protecting sensitive data from attackers bent on stealing your secrets.
|
||||
</description>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>MIT license</name>
|
||||
<url>http://opensource.org/licenses/MIT</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<id>marko</id>
|
||||
<name>Marko Zivanovic</name>
|
||||
<email>marko@zivanovic.in.rs</email>
|
||||
<url>http://marko.zivanovic.in.rs</url>
|
||||
<roles>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
<timezone>+1</timezone>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<organization>
|
||||
<name>Marko Zivanovic</name>
|
||||
<url>http://marko.zivanovic.in.rs</url>
|
||||
</organization>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.52</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
@@ -4,17 +4,11 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>rs.in.zivanovic</groupId>
|
||||
<artifactId>j-password-obfuscator</artifactId>
|
||||
<artifactId>j-password-obfuscator-parent</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<name>JPasswordObfuscator</name>
|
||||
<name>JPasswordObfuscator parent</name>
|
||||
<description>
|
||||
Extensible Java library and command line utility for sensitive data obfuscation and de-obfuscation.
|
||||
Solution for protecting passwords and other sensitive data in configuration files or in transit from casual glances.
|
||||
@@ -46,34 +40,10 @@
|
||||
<name>Marko Zivanovic</name>
|
||||
<url>http://marko.zivanovic.in.rs</url>
|
||||
</organization>
|
||||
|
||||
<modules>
|
||||
<module>jPasswordObfuscator-lib</module>
|
||||
<module>jPasswordObfuscator-bin</module>
|
||||
</modules>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.52</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.10</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>rs.in.zivanovic.obfuscator.Run</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user