summaryrefslogtreecommitdiffstats
path: root/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java')
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java58
1 files changed, 30 insertions, 28 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java
index 124c7ea0c8..c9147719a4 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/http/config/BasicAuthorization.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,7 +17,6 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.common.http.config;
import fj.data.Either;
@@ -25,6 +24,7 @@ import org.apache.commons.lang3.StringUtils;
import org.onap.sdc.security.SecurityUtil;
public class BasicAuthorization {
+
private String userName;
private String password;
@@ -36,36 +36,33 @@ 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) {
+ if (isEncoded) {
Either<String, String> passkey = SecurityUtil.INSTANCE.decrypt(password);
- if(passkey.isLeft()) {
+ if (passkey.isLeft()) {
this.password = passkey.left().value();
- }
- else {
+ } else {
throw new IllegalArgumentException(passkey.right().value());
}
- }
- else {
+ } else {
this.password = password;
}
}
@@ -81,25 +78,30 @@ public class BasicAuthorization {
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
BasicAuthorization other = (BasicAuthorization) obj;
if (password == null) {
- if (other.password != null)
+ if (other.password != null) {
return false;
- }
- else if (!password.equals(other.password))
+ }
+ } else if (!password.equals(other.password)) {
return false;
+ }
if (userName == null) {
- if (other.userName != null)
+ if (other.userName != null) {
return false;
- }
- else if (!userName.equals(other.userName))
+ }
+ } else if (!userName.equals(other.userName)) {
return false;
+ }
return true;
}
@@ -113,7 +115,7 @@ public class BasicAuthorization {
}
private void validate(String str) {
- if(StringUtils.isEmpty(str)) {
+ if (StringUtils.isEmpty(str)) {
throw new IllegalArgumentException("BasicAuthorization username and/or password cannot be empty");
}
}