|
|
@ -26,10 +26,12 @@ import org.wso2.carbon.context.CarbonContext;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo;
|
|
|
|
import org.wso2.carbon.device.mgt.core.service.EmailMetaInfo;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.beans.ErrorResponse;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.beans.OldPasswordResetWrapper;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.beans.UserList;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.beans.UserList;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.beans.UserWrapper;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.beans.UserWrapper;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.UserManagementService;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.service.api.UserManagementService;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.service.impl.util.UnexpectedServerErrorException;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.util.Constants;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.util.CredentialManagementResponseBuilder;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
|
|
|
import org.wso2.carbon.device.mgt.jaxrs.util.DeviceMgtAPIUtils;
|
|
|
@ -86,11 +88,13 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
String msg = "Exception in trying to add user '" + userWrapper.getUsername() + "' to the user store";
|
|
|
|
String msg = "Exception in trying to add user '" + userWrapper.getUsername() + "' to the user store";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
String msg = "ErrorResponse occurred while inviting user to enroll the device";
|
|
|
|
String msg = "ErrorResponse occurred while inviting user to enroll the device";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -188,7 +192,8 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
String msg = "ErrorResponse occurred while retrieving information of the user '" + username + "'";
|
|
|
|
String msg = "ErrorResponse occurred while retrieving information of the user '" + username + "'";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -246,7 +251,8 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|
|
|
} catch (UserStoreException | UnsupportedEncodingException e) {
|
|
|
|
} catch (UserStoreException | UnsupportedEncodingException e) {
|
|
|
|
String msg = "Exception in trying to update user by username: " + userWrapper.getUsername();
|
|
|
|
String msg = "Exception in trying to update user by username: " + userWrapper.getUsername();
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -294,7 +300,8 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
String msg = "Exception in trying to remove user by username: " + username;
|
|
|
|
String msg = "Exception in trying to remove user by username: " + username;
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -318,7 +325,8 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
String msg = "Exception in trying to retrieve roles for user by username: " + username;
|
|
|
|
String msg = "Exception in trying to retrieve roles for user by username: " + username;
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -356,9 +364,9 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|
|
|
offsetList = new ArrayList<>();
|
|
|
|
offsetList = new ArrayList<>();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (offsetList.size() <= 0) {
|
|
|
|
// if (offsetList.size() <= 0) {
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity("No users available for retrieval").build();
|
|
|
|
// return Response.status(Response.Status.NOT_FOUND).entity("No users available for retrieval").build();
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
UserList result = new UserList();
|
|
|
|
UserList result = new UserList();
|
|
|
|
result.setList(offsetList);
|
|
|
|
result.setList(offsetList);
|
|
|
@ -368,7 +376,8 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
String msg = "ErrorResponse occurred while retrieving the list of users.";
|
|
|
|
String msg = "ErrorResponse occurred while retrieving the list of users.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -394,14 +403,15 @@ public class UserManagementServiceImpl implements UserManagementService {
|
|
|
|
user.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME));
|
|
|
|
user.setLastname(getClaimValue(username, Constants.USER_CLAIM_LAST_NAME));
|
|
|
|
userList.add(user);
|
|
|
|
userList.add(user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (userList.size() <= 0) {
|
|
|
|
// if (userList.size() <= 0) {
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).entity("No user is available to be retrieved").build();
|
|
|
|
// return Response.status(Response.Status.NOT_FOUND).entity("No user is available to be retrieved").build();
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
return Response.status(Response.Status.OK).entity(userList).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(userList).build();
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
} catch (UserStoreException e) {
|
|
|
|
String msg = "ErrorResponse occurred while retrieving the list of users using the filter : " + filter;
|
|
|
|
String msg = "Error occurred while retrieving the list of users using the filter : " + filter;
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|