Adding back-end support for UI filters
[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    * Decrypt value.
44    *
45    * @param value the value
46    * @return the string
47    */
48   public String decryptValue(String value) {
49     String decyptedValue = "";
50
51     decyptedValue = Password.deobfuscate(value);
52
53     return decyptedValue;
54   }
55
56   /**
57    * Usage.
58    */
59   public static void usage() {
60     usage(null);
61   }
62
63   /**
64    * Usage.
65    *
66    * @param msg the msg
67    */
68   public static void usage(String msg) {
69     if (msg != null) {
70       System.err.println(msg);
71     }
72     System.err.println("Usage: java Encryptor -e value");
73     System.err.println("\tEncrypt the given value");
74     System.err.println("Usage: java Encryptor -d value");
75     System.err.println("\tDecrypt the given value");
76     System.exit(1);
77   }
78
79 }