* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/**
* A Class to run on command line to determine suitability of environment for certain TAFs.
- * *
+ * *
* @author Jonathan
*
*/
System.out.println(args[1]);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
b64.enpass(args[1], baos);
- String pass;
+ String pass;
System.out.println(pass=new String(baos.toByteArray()));
ByteArrayOutputStream reconstituted = new ByteArrayOutputStream();
b64.depass(pass, reconstituted);
}
System.out.flush();
*/
-
+
} catch (IOException e) {
System.err.println("Cannot digest password");
System.err.println(" \""+ e.getMessage() + '"');
}
// DO NOT LEAVE THIS METHOD Compiled IN CODE... Do not want looking at passwords on disk too easy
-// Jonathan. Oh, well, Deployment services need this behavior. I will put this code in, but leave it undocumented.
+// Jonathan. Oh, well, Deployment services need this behavior. I will put this code in, but leave it undocumented.
// One still needs access to the keyfile to read.
// July 2016 - thought of a tool "CMPass" to regurgitate from properties, but only if allowed.
- } else if ("regurgitate".equalsIgnoreCase(args[0]) && args.length>2) {
+ } else if (("regurgitate".equalsIgnoreCase(args[0]) || "undigest".equalsIgnoreCase(args[0]))
+ && args.length>2) {
try {
Symm symm;
FileInputStream fis = new FileInputStream(args[2]);
}
} else {
int idx;
- if ((idx = line.indexOf(' '))>=0
+ if ((idx = line.indexOf(' '))>=0
&& (idx = line.indexOf(' ',++idx))>0
&& (idx = line.indexOf('=',++idx))>0
) {
System.out.flush();
return;
} catch (IOException e) {
- System.err.println("Cannot regurgitate password");
+ System.err.println("Cannot undigest password");
System.err.println(" \""+ e.getMessage() + '"');
}
} else if ("encode64".equalsIgnoreCase(args[0]) && args.length>1) {
int salt = Integer.parseInt(args[i]);
System.out.println(Hash.hashSHA256asStringHex(args[1],salt));
}
- } else {
+ } else {
System.out.println(Hash.hashSHA256asStringHex(args[1]));
}
} catch (NoSuchAlgorithmException e) {
System.err.println("Cannot create a key " + args[0]);
System.err.println(" \""+ e.getMessage() + '"');
}
-
+
} else if ("passgen".equalsIgnoreCase(args[0])) {
int numDigits;
if (args.length <= 1) {
numDigits = 24;
} else {
- numDigits = Integer.parseInt(args[1]);
+ numDigits = Integer.parseInt(args[1]);
if (numDigits<8)numDigits = 8;
}
String pass;
}
if (noLower) {
noLower=!(c>=0x61 && c<=0x7A);
- }
+ }
if (noUpper) {
noUpper=!(c>=0x41 && c<=0x5A);
- }
+ }
if (noDigits) {
noDigits=!(c>=0x30 && c<=0x39);
- }
+ }
if (noSpecial) {
noSpecial = "+!@#$%^&*(){}[]?:;,.".indexOf(c)<0;
- }
-
+ }
+
missingChars = (noLower || noUpper || noDigits || noSpecial);
}
} while (missingChars || repeatingChars);
if (args.length <= 1) {
numDigits = 24;
} else {
- numDigits = Integer.parseInt(args[1]);
+ numDigits = Integer.parseInt(args[1]);
}
System.out.println(Symm.randomGen(Symm.base64url.codeset, numDigits).substring(0,numDigits));
}
System.out.println(" digest [<passwd>|-i|] <keyfile> (Encrypts Password with \"keyfile\"");
System.out.println(" if passwd = -i, will read StdIn");
System.out.println(" if passwd is blank, will ask securely)");
+ System.out.println(" undigest <enc:...> <keyfile> (Decrypts Encoded with \"keyfile\")");
System.out.println(" passgen <digits> (Generate Password of given size)");
System.out.println(" urlgen <digits> (Generate URL field of given size)");
System.out.println(" encode64 <your text> (Encodes to Base64)");
System.exit(1);
}
}
-
+
public static void setSystemExit(boolean shouldExit) {
systemExit = shouldExit;
}
-
+
}