summaryrefslogtreecommitdiffstats
path: root/security/crypt-password/src
diff options
context:
space:
mode:
authorZlatko Murgoski <zlatko.murgoski@nokia.com>2018-12-13 12:23:30 +0100
committerZlatko Murgoski <zlatko.murgoski@nokia.com>2018-12-13 13:29:13 +0100
commit2cf4d3c25895df964e3767ebd78ad75f1bb74619 (patch)
tree8619d167aa84c0a52e8b2dbf873f603c08ddf989 /security/crypt-password/src
parent445e345948ebd64c68a3944c5bfd64528340b781 (diff)
Tool for password cryptography
Tool for password cryptography Change-Id: I7713c8568a00409e282c250eefe4047458d3edac Issue-ID: DCAEGEN2-1020 Signed-off-by: Zlatko Murgoski <zlatko.murgoski@nokia.com>
Diffstat (limited to 'security/crypt-password/src')
-rw-r--r--security/crypt-password/src/main/java/org/onap/dcaegen2/services/sdk/security/CryptPassword.java35
-rw-r--r--security/crypt-password/src/main/java/org/onap/dcaegen2/services/sdk/security/DecodePassword.java34
2 files changed, 69 insertions, 0 deletions
diff --git a/security/crypt-password/src/main/java/org/onap/dcaegen2/services/sdk/security/CryptPassword.java b/security/crypt-password/src/main/java/org/onap/dcaegen2/services/sdk/security/CryptPassword.java
new file mode 100644
index 00000000..6ca78a01
--- /dev/null
+++ b/security/crypt-password/src/main/java/org/onap/dcaegen2/services/sdk/security/CryptPassword.java
@@ -0,0 +1,35 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.sdk.security;
+
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
+
+public class CryptPassword {
+
+ private BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
+
+ public String decode(String arg) {
+ return encoder.encode(arg);
+ }
+
+ public boolean matches(String rawPassword, String encodedPassword){
+ return encoder.matches(rawPassword,encodedPassword);
+ }
+}
diff --git a/security/crypt-password/src/main/java/org/onap/dcaegen2/services/sdk/security/DecodePassword.java b/security/crypt-password/src/main/java/org/onap/dcaegen2/services/sdk/security/DecodePassword.java
new file mode 100644
index 00000000..85412eb6
--- /dev/null
+++ b/security/crypt-password/src/main/java/org/onap/dcaegen2/services/sdk/security/DecodePassword.java
@@ -0,0 +1,34 @@
+/*
+ * ============LICENSE_START=======================================================
+ * DCAEGEN2-SERVICES-SDK
+ * ================================================================================
+ * Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dcaegen2.services.sdk.security;
+
+class DecodePassword {
+
+ private static CryptPassword cryptPassword = new CryptPassword();
+
+ public static void main(String[] args) {
+
+ try {
+ System.out.println(cryptPassword.decode(args[0]));
+ }catch(Exception e){
+ System.out.println("Param to crypt is required !");
+ }
+ }
+}