Merge "Fixed the critical issues sonar encountered"
[aai/sparky-be.git] / src / main / java / org / onap / aai / sparky / util / Encryptor.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 package org.onap.aai.sparky.util;
24
25 import org.apache.commons.cli.BasicParser;
26 import org.apache.commons.cli.CommandLine;
27 import org.apache.commons.cli.CommandLineParser;
28 import org.apache.commons.cli.Options;
29 import org.apache.commons.cli.ParseException;
30 import org.eclipse.jetty.util.security.Password;
31
32 /**
33  * The Class Encryptor.
34  */
35 public class Encryptor {
36
37   /**
38    * Instantiates a new encryptor.
39    */
40   public Encryptor() {  
41   }
42   
43   /**
44    * Decrypt value.
45    *
46    * @param value the value
47    * @return the string
48    */
49   public String decryptValue(String value) {
50     String decyptedValue = "";
51     
52       decyptedValue = Password.deobfuscate(value);
53   
54     return decyptedValue;
55   }
56
57   /**
58    * Usage.
59    */
60   public static void usage() {
61     usage(null);
62   }
63
64   /**
65    * Usage.
66    *
67    * @param msg the msg
68    */
69   public static void usage(String msg) {
70     if (msg != null) {
71       System.err.println(msg);
72     }
73     System.err.println("Usage: java Encryptor -e value");
74     System.err.println("\tEncrypt the given value");
75     System.err.println("Usage: java Encryptor -d value");
76     System.err.println("\tDecrypt the given value");
77     System.exit(1);
78   }
79
80 }