EasemobIMUsers { public static ObjectNode modifyIMUserPasswordWithAdminToken( String userPrimaryKey, ObjectNode dataObjectNode) { ObjectNode objectNode = factory.objectNode(); if (!JerseyUtils.match("^(?!-)[0-9a-zA-Z\\-]+#[0-9a-zA-Z]+", APPKEY)) { LOGGER.error("Bad format of Appkey: " + APPKEY); objectNode.put("message", "Bad format of Appkey"); return objectNode; } if (StringUtils.isEmpty(userPrimaryKey)) { LOGGER.error("Property that named userPrimaryKey must be provided，the value is username or uuid of imuser."); objectNode .put("message", "Property that named userPrimaryKey must be provided，the value is username or uuid of imuser."); return objectNode; } if (null != dataObjectNode && !dataObjectNode.has("newpassword")) { LOGGER.error("Property that named newpassword must be provided ."); objectNode.put("message", "Property that named newpassword must be provided ."); return objectNode; } try { JerseyWebTarget webTarget = null; webTarget = EndPoints.USERS_TARGET .resolveTemplate("org_name", APPKEY.split("#")[0]) .resolveTemplate("app_name", APPKEY.split("#")[1]) .path(userPrimaryKey).path("password"); objectNode = JerseyUtils.sendRequest(webTarget, dataObjectNode, credential, HTTPMethod.METHOD_PUT, null); } catch (Exception e) { e.printStackTrace(); } return objectNode; }  static ObjectNode createNewIMUserSingle(ObjectNode dataNode); static ObjectNode createNewIMUserBatch(ArrayNode dataArrayNode); static ObjectNode createNewIMUserBatchGen(String usernamePrefix,
			Long perNumber, Long totalNumber); static ObjectNode getIMUsersByPrimaryKey(String userPrimaryKey); static ObjectNode deleteIMUserByUserPrimaryKey(String userPrimaryKey); static ObjectNode deleteIMUserByUsernameBatch(Long limit,
			String queryStr); static ObjectNode modifyIMUserPasswordWithAdminToken(
			String userPrimaryKey, ObjectNode dataObjectNode); static ObjectNode addFriendSingle(String ownerUserPrimaryKey,
			String friendUserPrimaryKey); static ObjectNode deleteFriendSingle(String ownerUserPrimaryKey,
			String friendUserPrimaryKey); static ObjectNode getFriends(String ownerUserPrimaryKey); static ObjectNode imUserLogin(String ownerUserPrimaryKey, String password);  }
@Test public void testModifyIMUserPasswordWithAdminToken() throws Exception { String username = "kenshinnuser100"; ObjectNode json2 = JsonNodeFactory.instance.objectNode(); json2.put("newpassword", Constants.DEFAULT_PASSWORD); ObjectNode modifyIMUserPasswordWithAdminTokenNode = EasemobIMUsers.modifyIMUserPasswordWithAdminToken(username, json2); if (null != modifyIMUserPasswordWithAdminTokenNode) { LOGGER.info("重置IM用户密码 提供管理员token: " + modifyIMUserPasswordWithAdminTokenNode.toString()); } ObjectNode imUserLoginNode2 = EasemobIMUsers.imUserLogin(username, json2.get("newpassword").asText()); if (null != imUserLoginNode2) { LOGGER.info("重置IM用户密码后,IM用户登录: " + imUserLoginNode2.toString()); } }