Update SDC with new 'security-util-lib' version
[sdc.git] / common-app-api / src / main / java / org / openecomp / sdc / common / http / config / BasicAuthorization.java
index 47338b7..4e0af9c 100644 (file)
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-
 package org.openecomp.sdc.common.http.config;
 
 import fj.data.Either;
 import org.apache.commons.lang3.StringUtils;
-import org.openecomp.sdc.security.SecurityUtil;
+import org.onap.sdc.security.SecurityUtil;
 
 public class BasicAuthorization {
+
     private String userName;
     private String password;
 
@@ -36,28 +36,27 @@ public class BasicAuthorization {
         setPassword(basicAuthorization.password, false);
     }
 
+    public String getUserName() {
+        return userName;
+    }
+
     public void setUserName(String userName) {
         validate(userName);
         this.userName = userName;
     }
 
-    public void setPassword(String password) {
-        setPassword(password, true);
-    }
-
-    public String getUserName() {
-        return userName;
-    }
-
     public String getPassword() {
         return password;
     }
 
+    public void setPassword(String password) {
+        setPassword(password, true);
+    }
 
     private void setPassword(String password, boolean isEncoded) {
         validate(password);
         if (isEncoded) {
-            Either<String, String> passkey = SecurityUtil.INSTANCE.decrypt(password);
+            Either<String, String> passkey = SecurityUtil.decrypt(password);
             if (passkey.isLeft()) {
                 this.password = passkey.left().value();
             } else {
@@ -97,10 +96,13 @@ public class BasicAuthorization {
             return false;
         }
         if (userName == null) {
-            return other.userName == null;
-        } else {
-            return userName.equals(other.userName);
+            if (other.userName != null) {
+                return false;
+            }
+        } else if (!userName.equals(other.userName)) {
+            return false;
         }
+        return true;
     }
 
     @Override