From 2cf4d3c25895df964e3767ebd78ad75f1bb74619 Mon Sep 17 00:00:00 2001 From: Zlatko Murgoski Date: Thu, 13 Dec 2018 12:23:30 +0100 Subject: Tool for password cryptography Tool for password cryptography Change-Id: I7713c8568a00409e282c250eefe4047458d3edac Issue-ID: DCAEGEN2-1020 Signed-off-by: Zlatko Murgoski --- pom.xml | 1 + security/crypt-password/README.md | 10 ++++ security/crypt-password/pom.xml | 54 ++++++++++++++++++++++ .../services/sdk/security/CryptPassword.java | 35 ++++++++++++++ .../services/sdk/security/DecodePassword.java | 34 ++++++++++++++ security/pom.xml | 26 +++++++++++ 6 files changed, 160 insertions(+) create mode 100644 security/crypt-password/README.md create mode 100644 security/crypt-password/pom.xml create mode 100644 security/crypt-password/src/main/java/org/onap/dcaegen2/services/sdk/security/CryptPassword.java create mode 100644 security/crypt-password/src/main/java/org/onap/dcaegen2/services/sdk/security/DecodePassword.java create mode 100644 security/pom.xml diff --git a/pom.xml b/pom.xml index 1cd81a22..1d08659a 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,7 @@ rest-services + security diff --git a/security/crypt-password/README.md b/security/crypt-password/README.md new file mode 100644 index 00000000..1ce79273 --- /dev/null +++ b/security/crypt-password/README.md @@ -0,0 +1,10 @@ +Crypt Password +================================== + +Library to generate and match cryptography password using BCrypt algorithm + +### Requirements +mvn clean install + +### How to use +java -jar crypt-password-.jar password_to_crypt \ No newline at end of file diff --git a/security/crypt-password/pom.xml b/security/crypt-password/pom.xml new file mode 100644 index 00000000..bdb3bb4b --- /dev/null +++ b/security/crypt-password/pom.xml @@ -0,0 +1,54 @@ + + + + + org.onap.dcaegen2.services.sdk.security + dcaegen2-services-sdk-security + 1.0.0-SNAPSHOT + + 4.0.0 + + org.onap.dcaegen2.services.sdk.security.crypt + crypt-password + 1.0.0-SNAPSHOT + + dcaegen2-services-sdk-security-crypt-password + DMaaP Security Module + jar + + + + org.springframework.security + spring-security-crypto + 3.1.0.RELEASE + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.2.1 + + + package + + shade + + + + + org.onap.dcaegen2.services.sdk.security.DecodePassword + + + + + + + + + + \ No newline at end of file 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 !"); + } + } +} diff --git a/security/pom.xml b/security/pom.xml new file mode 100644 index 00000000..66b7a0ff --- /dev/null +++ b/security/pom.xml @@ -0,0 +1,26 @@ + + + 4.0.0 + + + org.onap.dcaegen2.services + sdk + 1.0.0-SNAPSHOT + ../pom.xml + + + org.onap.dcaegen2.services.sdk.security + dcaegen2-services-sdk-security + 1.0.0-SNAPSHOT + + dcaegen2-services-sdk-security + Common SDK repo for all DCAE Security + pom + + + crypt-password + + + \ No newline at end of file -- cgit 1.2.3-korg