2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.aai.util;
\r
24 import org.apache.commons.cli.BasicParser;
\r
25 import org.apache.commons.cli.CommandLine;
\r
26 import org.apache.commons.cli.CommandLineParser;
\r
27 import org.apache.commons.cli.Options;
\r
28 import org.apache.commons.cli.ParseException;
\r
29 import org.eclipse.jetty.util.security.Password;
\r
32 public class JettyObfuscationConversionCommandLineUtil {
\r
36 * @param args the arguments
\r
38 public static void main(String[] args){
\r
39 Options options = new Options();
\r
40 options.addOption("e", true, "obfuscate the given string");
\r
41 options.addOption("d", true, "deobfuscate the given string");
\r
43 CommandLineParser parser = new BasicParser();
\r
46 CommandLine cmd = parser.parse(options, args);
\r
47 String toProcess = null;
\r
49 if (cmd.hasOption("e")){
\r
50 toProcess = cmd.getOptionValue("e");
\r
51 String encoded = Password.obfuscate(toProcess);
\r
52 System.out.println(encoded);
\r
53 } else if (cmd.hasOption("d")) {
\r
54 toProcess = cmd.getOptionValue("d");
\r
55 String decoded_str = Password.deobfuscate(toProcess);
\r
56 System.out.println(decoded_str);
\r
60 } catch (ParseException e) {
\r
61 System.out.println("failed to parse input");
\r
62 System.out.println(e.toString());
\r
64 } catch (Exception e) {
\r
65 System.out.println("exception:" + e.toString());
\r
72 private static void usage(){
\r
73 System.out.println("usage:");;
\r
74 System.out.println("-e [string] to obfuscate");
\r
75 System.out.println("-d [string] to deobfuscate");
\r
76 System.out.println("-h help");
\r