1 package de.webman.util.security; 2 3 import java.io.BufferedReader ; 4 import java.io.InputStreamReader ; 5 import java.io.IOException ; 6 7 14 15 public class EncryptTool 16 { 17 18 19 23 public static void showLine(String str) { 24 System.out.println(str + " -> " + EncryptUtil.encrypt(str)); 25 } 26 27 30 private static void showUsage() { 31 System.out.println("java de.webman.util.security.EncryptTool [options] [PASSWORD ...]"); 32 System.out.println(""); 33 System.out.println("Options:"); 34 System.out.println(" --help this help"); 35 System.out.println(""); 36 System.out.println("wm-encrypt encrypt passwords using MD5 and printing them "); 37 System.out.println("base64 encoded to stdout. If no passwords are given on the"); 38 System.out.println("command line, the tools requests them interactively from"); 39 System.out.println("stdin. Please note, that encrypted passwords never contains"); 40 System.out.println("any whitespace. You may past and copy the passwords into"); 41 System.out.println("the ldap.xml file used by the synchronization mechanism."); 42 System.out.println(""); 43 } 44 45 49 public static void main(String [] args) { 50 51 if (args.length == 0) { 52 try { 53 BufferedReader brd = new BufferedReader (new InputStreamReader (System.in)); 54 boolean done = false; 55 56 while (!done) { 57 System.out.print("* "); 58 System.out.flush(); 59 String line = brd.readLine(); 60 61 if (line == null) 62 done = true; 63 else { 64 showLine(line.trim()); 65 } 66 } 67 68 brd.close(); 69 } 70 catch (IOException ioe) { 71 System.err.println(ioe); 72 System.exit(-1); 73 } 74 } 75 else { 76 for (int l = 0; l < args.length; l++) { 77 if ("--help".equals(args[l]) || "-h".equals(args[l])) { 78 showUsage(); 79 System.exit(0); 80 } 81 else 82 showLine(args[l]); 83 } 84 } 85 } 86 } 87 | Popular Tags |