Skip to content
Snippets Groups Projects
Commit 6ce89971 authored by Rick Herrick's avatar Rick Herrick
Browse files

XNAT-2840 XNAT-4394 XNAT-4500 Added REST API functions to list and

invalidate user sessions. Fixed investigator initialization error. Fixed
password handling for new user operations.
parent 3d64b757
No related branches found
No related tags found
No related merge requests found
package org.nrg.xapi.model.users;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;
import org.nrg.xdat.entities.UserAuthI;
import org.nrg.xdat.om.XdatUser;
import org.nrg.xdat.om.base.auto.AutoXdatUser;
import org.nrg.xdat.security.XDATUser;
import org.nrg.xft.security.UserI;
import java.util.Date;
@ApiModel(description = "Contains the properties that define a user on the system.")
@JsonIgnoreProperties(value = {"FullName", "Password", "Salt", "XdatUser"}, ignoreUnknown = true)
public class User {
public User() {
// Nothing to see here...
}
public User(final String username) {
......@@ -28,11 +27,11 @@ public class User {
_lastName = user.getLastname();
_email = user.getEmail();
_isAdmin = (user instanceof XDATUser && ((XDATUser) user).isSiteAdmin());
_dbName = "";
_password = "";
_salt = "";
_lastModified = null;
_authorization = null;
_dbName = user.getDBName();
_password = user.getPassword();
_salt = user.getSalt();
_lastModified = user.getLastModified();
_authorization = user.getAuthorization();
_isEnabled = user.isEnabled();
_isVerified = user.isVerified();
}
......@@ -143,6 +142,7 @@ public class User {
* The user's encrypted password.
**/
@ApiModelProperty(value = "The user's encrypted password.")
@JsonIgnore
public String getPassword() {
return _password;
}
......@@ -155,6 +155,7 @@ public class User {
* The _salt used to encrypt the user's _password.
**/
@ApiModelProperty(value = "The salt used to encrypt the user's password.")
@JsonIgnore
public String getSalt() {
return _salt;
}
......@@ -180,23 +181,23 @@ public class User {
* The user's authorization record used when logging in.
**/
@ApiModelProperty(value = "The user's authorization record used when logging in.")
public UserAuth getAuthorization() {
public UserAuthI getAuthorization() {
return _authorization;
}
@SuppressWarnings("unused")
public void setAuthorization(UserAuth authorization) {
public void setAuthorization(UserAuthI authorization) {
_authorization = authorization;
}
@ApiModelProperty(value = "The user's full name.")
@JsonIgnore
public String getFullName() {
return String.format("%s %s", getFirstName(), getLastName());
}
@Override
public String toString() {
return "class User {\n" +
" id: " + _id + "\n" +
" username: " + _username + "\n" +
......@@ -211,17 +212,17 @@ public class User {
"}\n";
}
private Integer _id = null;
private String _username = null;
private String _firstName = null;
private String _lastName = null;
private String _email = null;
private boolean _isAdmin;
private String _dbName = null;
private String _password = null;
private String _salt = null;
private Date _lastModified = null;
private UserAuth _authorization = null;
private boolean _isEnabled;
private boolean _isVerified;
private Integer _id;
private String _username;
private String _firstName;
private String _lastName;
private String _email;
private String _dbName;
private String _password;
private String _salt;
private Date _lastModified;
private UserAuthI _authorization;
private boolean _isAdmin;
private boolean _isEnabled;
private boolean _isVerified;
}
package org.nrg.xapi.rest.data;
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.apache.commons.lang3.NotImplementedException;
import org.nrg.xdat.bean.XnatInvestigatordataBean;
import org.nrg.xdat.model.XnatInvestigatordataI;
import org.nrg.xdat.om.XnatInvestigatordata;
......@@ -19,6 +18,10 @@ import java.util.*;
* associated.
*/
public class Investigator implements XnatInvestigatordataI {
public Investigator() {
//
}
public Investigator(final XnatInvestigatordataI investigator, final Collection<String> primaryProjects, final Collection<String> investigatorProjects) {
_xnatInvestigatordataId = investigator.getXnatInvestigatordataId();
_id = investigator.getId();
......@@ -65,7 +68,7 @@ public class Investigator implements XnatInvestigatordataI {
@Override
public void setTitle(final String title) {
throw new NotImplementedException("Set methods on this class are not implemented: the class is meant to be read-only and only for reference purposes.");
_title = title;
}
@Override
......@@ -75,7 +78,7 @@ public class Investigator implements XnatInvestigatordataI {
@Override
public void setFirstname(final String firstname) {
throw new NotImplementedException("Set methods on this class are not implemented: the class is meant to be read-only and only for reference purposes.");
_firstname = firstname;
}
@Override
......@@ -85,7 +88,7 @@ public class Investigator implements XnatInvestigatordataI {
@Override
public void setLastname(final String lastname) {
throw new NotImplementedException("Set methods on this class are not implemented: the class is meant to be read-only and only for reference purposes.");
_lastname = lastname;
}
@Override
......@@ -95,7 +98,7 @@ public class Investigator implements XnatInvestigatordataI {
@Override
public void setInstitution(final String institution) {
throw new NotImplementedException("Set methods on this class are not implemented: the class is meant to be read-only and only for reference purposes.");
_institution = institution;
}
@Override
......@@ -105,7 +108,7 @@ public class Investigator implements XnatInvestigatordataI {
@Override
public void setDepartment(final String department) {
throw new NotImplementedException("Set methods on this class are not implemented: the class is meant to be read-only and only for reference purposes.");
_department = department;
}
@Override
......@@ -115,7 +118,7 @@ public class Investigator implements XnatInvestigatordataI {
@Override
public void setEmail(final String email) {
throw new NotImplementedException("Set methods on this class are not implemented: the class is meant to be read-only and only for reference purposes.");
_email = email;
}
@Override
......@@ -125,7 +128,7 @@ public class Investigator implements XnatInvestigatordataI {
@Override
public void setPhone(final String phone) {
throw new NotImplementedException("Set methods on this class are not implemented: the class is meant to be read-only and only for reference purposes.");
_phone = phone;
}
@Override
......@@ -134,8 +137,8 @@ public class Investigator implements XnatInvestigatordataI {
}
@Override
public void setId(final String v) {
throw new NotImplementedException("Set methods on this class are not implemented: the class is meant to be read-only and only for reference purposes.");
public void setId(final String id) {
_id = id;
}
@Override
......@@ -143,6 +146,11 @@ public class Investigator implements XnatInvestigatordataI {
return _xnatInvestigatordataId;
}
@SuppressWarnings("unused")
public void setXnatInvestigatordataId(final Integer xnatInvestigatordataId) {
_xnatInvestigatordataId = xnatInvestigatordataId;
}
/**
* Gets the list of IDs for projects on which the investigator is the primary investigator.
*
......@@ -199,15 +207,15 @@ public class Investigator implements XnatInvestigatordataI {
return Arrays.asList(projectIds);
}
private final Integer _xnatInvestigatordataId;
private final String _id;
private final String _title;
private final String _firstname;
private final String _lastname;
private final String _institution;
private final String _department;
private final String _email;
private final String _phone;
private Integer _xnatInvestigatordataId;
private String _id;
private String _title;
private String _firstname;
private String _lastname;
private String _institution;
private String _department;
private String _email;
private String _phone;
private final Set<String> _primaryProjects = new HashSet<>();
private final Set<String> _investigatorProjects = new HashSet<>();
}
......@@ -10,7 +10,6 @@ import org.nrg.xdat.om.XnatInvestigatordata;
import org.nrg.xdat.rest.AbstractXapiRestController;
import org.nrg.xdat.security.helpers.Roles;
import org.nrg.xdat.security.services.RoleHolder;
import org.nrg.xdat.security.services.RoleRepositoryServiceI;
import org.nrg.xdat.security.services.UserManagementServiceI;
import org.nrg.xft.XFTItem;
import org.nrg.xft.event.EventUtils;
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment