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