2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 - 2019 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.*;
25 import org.eclipse.jetty.util.security.Password;
28 public class JettyObfuscationConversionCommandLineUtil {
32 * @param args the arguments
34 public static void main(String[] args){
35 Options options = new Options();
36 options.addOption("e", true, "obfuscate the given string");
37 options.addOption("d", true, "deobfuscate the given string");
39 CommandLineParser parser = new BasicParser();
42 CommandLine cmd = parser.parse(options, args);
43 String toProcess = null;
45 if (cmd.hasOption("e")){
46 toProcess = cmd.getOptionValue("e");
47 String encoded = Password.obfuscate(toProcess);
48 System.out.println(encoded);
49 } else if (cmd.hasOption("d")) {
50 toProcess = cmd.getOptionValue("d");
51 String decodedStr = Password.deobfuscate(toProcess);
52 System.out.println(decodedStr);
56 } catch (ParseException e) {
57 System.out.println("failed to parse input");
58 System.out.println(e.toString());
60 } catch (Exception e) {
61 System.out.println("exception:" + e.toString());
68 private static void usage(){
69 System.out.println("usage:");
70 System.out.println("-e [string] to obfuscate");
71 System.out.println("-d [string] to deobfuscate");
72 System.out.println("-h help");