}
return result;
}
-
+
protected UriInfo createUriInfo() throws URISyntaxException {
return createUriInfo("");
}
*/
private String getAccountCsid(String userId) {
String result = null;
-
+
try {
UriInfo uriInfo = createUriInfo(String.format("uid=%s", userId));
AccountsCommonList accountsCommonList = getAccountList(uriInfo);
// TODO Auto-generated catch block
e.printStackTrace();
}
-
+
return result;
}
-
+
/**
* Return the list of roles (display name) for a user id.
- *
+ *
* @param userId
* @return
*/
public List<String> getAccountRoles(String userId, String tenantId) {
List<String> result = null;
-
+
String accountCsid = getAccountCsid(userId);
if (accountCsid != null) {
AccountRole accountRole = getAccountRole(accountCsid);
}
}
}
-
+
return result;
}
public AccountsCommon updateAccount(@Context UriInfo ui, @PathParam("csid") String csid,AccountsCommon theUpdate) {
return (AccountsCommon)update(ui, csid, theUpdate, AccountsCommon.class);
}
-
+
/**
* Resets an accounts password.
- *
+ *
* Requires three query params:
* id = CSID of the account
* token = the password reset token generated by the system
* password = the new password
- *
+ *
* @param ui
* @return
*/
@POST
@Path(PROCESS_PASSWORD_RESET_PATH)
public Response processPasswordReset(@Context UriInfo ui) {
- Response response = null;
+ Response response = null;
//
// Create a read/write copy of the UriInfo info
//
ui = new UriInfoWrapper(ui);
MultivaluedMap<String,String> queryParams = ui.getQueryParameters();
-
+
//
// Get the 'token' and 'password' params
//
"The query parameter 'token' is missing or contains no value.").type("text/plain").build();
return response;
}
-
+
String password = queryParams.getFirst("password");
if (password == null || password.trim().isEmpty()) {
response = Response.status(Response.Status.BAD_REQUEST).entity(
"The query parameter 'password' is missing or contains no value.").type("text/plain").build();
return response;
}
-
+
//
// Retrieve the token from the DB
//
response = Response.status(Response.Status.BAD_REQUEST).entity(errMsg).type("text/plain").build();
return response;
}
-
+
//
// Make sure the token is not null
//
response = Response.status(Response.Status.BAD_REQUEST).entity(errMsg).type("text/plain").build();
return response;
}
-
+
//
// From the token, get the account to update.
//
response = Response.status(Response.Status.BAD_REQUEST).entity(errMsg).type("text/plain").build();
return response;
}
-
+
//
//
//
updateAccount(ui, targetAccount.getCsid(), accountUpdate);
String msg = String.format("Successfully reset password using token ID='%s'.",
token.getId());
- response = Response.status(Response.Status.OK).entity(msg).type("text/plain").build();
+ response = Response.status(Response.Status.OK).entity(msg).type("text/plain").build();
} else {
String errMsg = String.format("Could not reset password using token with ID='%s'. Password reset token has expired.",
token.getId());
tenantId);
response = Response.status(Response.Status.BAD_REQUEST).entity(errMsg).type("text/plain").build();
}
-
+
return response;
}
-
+
@POST
@Path(PASSWORD_RESET_PATH)
public Response requestPasswordReset(@Context UriInfo ui) {
Response response = null;
-
- MultivaluedMap<String,String> queryParams = ui.getQueryParameters();
+
+ MultivaluedMap<String,String> queryParams = ui.getQueryParameters();
String email = queryParams.getFirst(AccountClient.EMAIL_QUERY_PARAM);
if (email == null) {
response = Response.status(Response.Status.BAD_REQUEST).entity("You must specify an 'email' query paramater.").type("text/plain").build();
response = Response.status(Response.Status.BAD_REQUEST).entity("You must specify an 'tid' (tenant ID) query paramater.").type("text/plain").build();
return response;
}
-
+
AccountsCommonList accountList = getAccountList(ui);
if (accountList == null || accountList.getTotalItems() == 0) {
- response = Response.status(Response.Status.NOT_FOUND).entity("Could not locatate an account associated with the email: " +
+ response = Response.status(Response.Status.NOT_FOUND).entity("Could not locate an account associated with the email: " +
email).type("text/plain").build();
} else if (accountList.getTotalItems() > 1) {
response = Response.status(Response.Status.BAD_REQUEST).entity("Located more than one account associated with the email: " +
private boolean contains(String targetTenantID, List<AccountTenant> accountTenantList) {
boolean result = false;
-
+
for (AccountTenant accountTenant : accountTenantList) {
if (accountTenant.getTenantId().equalsIgnoreCase(targetTenantID)) {
result = true;
break;
}
}
-
+
return result;
}
*/
private Response requestPasswordReset(UriInfo ui, String targetTenantID, AccountListItem accountListItem) throws Exception {
Response result = null;
-
+
if (contains(targetTenantID, accountListItem.getTenants()) == false) {
- String errMsg = String.format("Could not send a password request email to user ID='%s'. That account is not associtated with the targeted tenant ID = '%s'.",
+ String errMsg = String.format("Could not send a password request email to user ID='%s'. That account is not associated with the targeted tenant ID = '%s'.",
accountListItem.email, targetTenantID);
result = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).type("text/plain").build();
return result;
String baseUrl = baseUrlBuilder.replacePath(null).build(emptyValues).toString();
emailConfig.setBaseurl(baseUrl);
//
- // Configuring (via config files) the base URL is not supported as of CSpace v5.0. Log a warning if we find config for it.
+ // Configuring (via config files) the base URL is not supported as of CSpace v5.0. Log a warning if we find config for it.
//
if (deprecatedConfigBaseUrl != null) {
if (deprecatedConfigBaseUrl.equalsIgnoreCase(baseUrl) == false) {
- String warnMsg = String.format("Ignoring deprecated 'baseurl' email config value '%s'. Using '%s' instead.",
+ String warnMsg = String.format("Ignoring deprecated 'baseurl' email config value '%s'. Using '%s' instead.",
deprecatedConfigBaseUrl, baseUrl);
logger.warn(warnMsg);
}
if (status != null) {
String errMsg = String.format("Could not send a password request email to user ID='%s'. Error: '%s'",
accountListItem.email, status);
- result = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).type("text/plain").build();
+ result = Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errMsg).type("text/plain").build();
} else {
- String okMsg = String.format("Password reset email send to '%s'.", accountListItem.getEmail());
+ String okMsg = String.format("Password reset email sent to '%s'.", accountListItem.getEmail());
result = Response.status(Response.Status.OK).entity(okMsg).type("text/plain").build();
}
} else {
AccountsCommon account = (AccountsCommon)get(csid, AccountsCommon.class);
// If marked as metadata immutable, do not delete
if(AccountClient.IMMUTABLE.equals(account.getMetadataProtection())) {
- Response response =
+ Response response =
Response.status(Response.Status.FORBIDDEN).entity("Account: "+csid+" is immutable.").type("text/plain").build();
return response;
}
AccountsCommon account = (AccountsCommon)get(accCsid, AccountsCommon.class);
// If marked as roles immutable, do not create
if(AccountClient.IMMUTABLE.equals(account.getRolesProtection())) {
- Response response =
+ Response response =
Response.status(Response.Status.FORBIDDEN).entity("Roles for Account: "+accCsid+" are immutable.").type("text/plain").build();
return response;
}
checkResult(result, accCsid, ServiceMessages.GET_FAILED);
return result;
}
-
+
@GET
@Path("{csid}/accountroles")
public AccountRole getAccountRole(
checkResult(result, accCsid, ServiceMessages.GET_FAILED);
return result;
}
-
+
public Response deleteAccountRole(String accCsid, AccountRole input) {
logger.debug("deleteAccountRole with accCsid=" + accCsid);
ensureCSID(accCsid, ServiceMessages.DELETE_FAILED+ "accountroles account ");
AccountsCommon account = (AccountsCommon)get(accCsid, AccountsCommon.class);
// If marked as roles immutable, do not delete
if(AccountClient.IMMUTABLE.equals(account.getRolesProtection())) {
- Response response =
+ Response response =
Response.status(Response.Status.FORBIDDEN).entity("Roles for Account: "+accCsid+" are immutable.").type("text/plain").build();
return response;
}
throw bigReThrow(e, ServiceMessages.DELETE_FAILED, accCsid);
}
}
-
+
@DELETE
@Path("{csid}/accountroles")
public Response deleteAccountRole(@PathParam("csid") String accCsid) {
// If marked as roles immutable, do not delete
AccountsCommon account = (AccountsCommon)get(accCsid, AccountsCommon.class);
if(AccountClient.IMMUTABLE.equals(account.getRolesProtection())) {
- Response response =
+ Response response =
Response.status(Response.Status.FORBIDDEN).entity("Roles for Account: "+accCsid+" are immutable.").type("text/plain").build();
return response;
}