import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.opendaylight.controller.sal.authorization.AuthResultEnum;
import org.opendaylight.controller.sal.utils.Status;
import org.opendaylight.controller.sal.utils.StatusCode;
this.roles = (roles == null) ? new ArrayList<String>()
: new ArrayList<String>(roles);
}
-
+
public String getUser() {
return user;
}
@Override
public int hashCode() {
- return HashCodeBuilder.reflectionHashCode(this);
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((password == null) ? 0 : password.hashCode());
+ result = prime * result + ((roles == null) ? 0 : roles.hashCode());
+ result = prime * result + ((user == null) ? 0 : user.hashCode());
+ return result;
}
@Override
public boolean equals(Object obj) {
- return EqualsBuilder.reflectionEquals(this, obj);
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ UserConfig other = (UserConfig) obj;
+ if (password == null) {
+ if (other.password != null)
+ return false;
+ } else if (!password.equals(other.password))
+ return false;
+ if (roles == null) {
+ if (other.roles != null)
+ return false;
+ } else if (!roles.equals(other.roles))
+ return false;
+ if (user == null) {
+ if (other.user != null)
+ return false;
+ } else if (!user.equals(other.user))
+ return false;
+ return true;
}
@Override
return new Status(StatusCode.BADREQUEST,
"Current password is incorrect");
}
-
+
// Create a new object with the proposed modifications
UserConfig proposed = new UserConfig();
proposed.user = this.user;
proposed.password = (newPassword != null)? newPassword : this.password;
proposed.roles = (newRoles != null)? newRoles : this.roles;
-
+
// Validate it
Status status = proposed.validate();
if (!status.isSuccess()) {
return status;
}
-
+
// Accept the modifications
this.user = proposed.user;
this.password = proposed.password;
this.roles = new ArrayList<String>(proposed.roles);
-
+
return status;
}
}
return locResponse;
}
-
+
protected String getRolesString() {
StringBuffer buffer = new StringBuffer();
if (!roles.isEmpty()) {