当前位置: 首页>>代码示例>>Java>>正文


Java User.setPassword方法代码示例

本文整理汇总了Java中org.jivesoftware.openfire.user.User.setPassword方法的典型用法代码示例。如果您正苦于以下问题:Java User.setPassword方法的具体用法?Java User.setPassword怎么用?Java User.setPassword使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.openfire.user.User的用法示例。


在下文中一共展示了User.setPassword方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateUser

import org.jivesoftware.openfire.user.User; //导入方法依赖的package包/类
/**
 * Update user.
 *
 * @param username
 *            the username
 * @param userEntity
 *            the user entity
 * @throws ServiceException
 *             the service exception
 */
public void updateUser(String username, UserEntity userEntity) throws ServiceException {
    if (userEntity != null && !username.isEmpty()) {
        User user = getAndCheckUser(username);
        if (userEntity.getPassword() != null) {
            user.setPassword(userEntity.getPassword());
        }
        if (userEntity.getName() != null) {
            user.setName(userEntity.getName());
        }
        if (userEntity.getEmail() != null) {
            user.setEmail(userEntity.getEmail());
        }

        addProperties(userEntity);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:27,代码来源:UserServicePluginNG.java

示例2: updateUser

import org.jivesoftware.openfire.user.User; //导入方法依赖的package包/类
public static boolean updateUser(String appId, MMXUserInfo userCreationInfo) throws ServerNotInitializedException, UserNotFoundException {
  boolean created = false;
  try {
    User user = getUserManager().getUser(userCreationInfo.getMMXUsername(appId));
    String password = userCreationInfo.getPassword();
    String name = userCreationInfo.getName();
    String email = userCreationInfo.getEmail();
    Boolean isAdmin = userCreationInfo.getIsAdmin();
    if (password != null) user.setPassword(password);
    if (name != null) user.setName(name);
    if (email != null) user.setEmail(email);
    if(isAdmin != null) {
      AdminManager adminManager = AdminManager.getInstance();
      if (isAdmin == true) {
        if(adminManager == null)
          throw new ServerNotInitializedException();
        adminManager.addAdminAccount(user.getUsername());
      } else if (isAdmin == false) {
        adminManager.removeAdminAccount(user.getUsername());
      }
    }
  } catch (UserNotFoundException e) {
    LOGGER.trace("updateUser : user does not exist, creating a user userCreationInfo={}", userCreationInfo);
    try {
      createUser(appId, userCreationInfo);
      created = true;
    } catch (UserAlreadyExistsException e1) {
      LOGGER.error("updateUser : user did not exist but creation failed  userCreationInfo={}", userCreationInfo);
      throw e;
    }
  }
  return created;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:34,代码来源:UserManagerService.java

示例3: execute

import org.jivesoftware.openfire.user.User; //导入方法依赖的package包/类
@Override
public void execute(SessionData data, Element command) {
    Element note = command.addElement("note");
    // Check if groups cannot be modified (backend is read-only)
    if (UserManager.getUserProvider().isReadOnly()) {
        note.addAttribute("type", "error");
        note.setText("Users are read only. Changing password is not allowed.");
        return;
    }
    JID account = new JID(data.getData().get("accountjid").get(0));
    String newPassword = data.getData().get("password").get(0);
    if (!XMPPServer.getInstance().isLocal(account)) {
        note.addAttribute("type", "error");
        note.setText("Cannot change password of remote user.");
        return;
    }
    // Get requested group
    User user;
    try {
        user = UserManager.getInstance().getUser(account.getNode());
    } catch (UserNotFoundException e) {
        // Group not found
        note.addAttribute("type", "error");
        note.setText("User does not exists.");
        return;
    }
    // Set the new passowrd of the user
    user.setPassword(newPassword);
    // Answer that the operation was successful
    note.addAttribute("type", "info");
    note.setText("Operation finished successfully");
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:33,代码来源:ChangeUserPassword.java

示例4: updateUser

import org.jivesoftware.openfire.user.User; //导入方法依赖的package包/类
/**
 * Update user.
 *
 * @param username
 *            the username
 * @param userEntity
 *            the user entity
 * @throws ServiceException
 *             the service exception
 */
public void updateUser(String username, UserEntity userEntity) throws ServiceException {
    if (userEntity != null && !username.isEmpty()) {
        // Payload contains another username than provided over path
        // parameter
        if (userEntity.getUsername() != null) {
            if (!userEntity.getUsername().equals(username)) {
                JustMarriedController.changeName(username, userEntity.getUsername(), true, userEntity.getEmail(),
                        userEntity.getName());
                addProperties(userEntity.getUsername(), userEntity.getProperties());
                return;
            }
        }
        User user = getAndCheckUser(username);
        if (userEntity.getPassword() != null) {
            user.setPassword(userEntity.getPassword());
        }
        if (userEntity.getName() != null) {
            user.setName(userEntity.getName());
        }
        if (userEntity.getEmail() != null) {
            user.setEmail(userEntity.getEmail());
        }

        addProperties(username, userEntity.getProperties());
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:37,代码来源:UserServiceController.java

示例5: execute

import org.jivesoftware.openfire.user.User; //导入方法依赖的package包/类
@Override
public void execute(SessionData data, Element command) {
       Element note = command.addElement("note");
       // Check if groups cannot be modified (backend is read-only)
       if (UserManager.getUserProvider().isReadOnly()) {
           note.addAttribute("type", "error");
           note.setText("Users are read only. Changing password is not allowed.");
           return;
       }
       JID account = new JID(data.getData().get("accountjid").get(0));
       String newPassword = data.getData().get("password").get(0);
       if (!XMPPServer.getInstance().isLocal(account)) {
           note.addAttribute("type", "error");
           note.setText("Cannot change password of remote user.");
           return;
       }
       // Get requested group
       User user;
       try {
           user = UserManager.getInstance().getUser(account.getNode());
       } catch (UserNotFoundException e) {
           // Group not found
           note.addAttribute("type", "error");
           note.setText("User does not exists.");
           return;
       }
       // Set the new passowrd of the user
       user.setPassword(newPassword);
       // Answer that the operation was successful
       note.addAttribute("type", "info");
       note.setText("Operation finished successfully");
   }
 
开发者ID:coodeer,项目名称:g3server,代码行数:33,代码来源:ChangeUserPassword.java

示例6: handlegetPassword

import org.jivesoftware.openfire.user.User; //导入方法依赖的package包/类
private void handlegetPassword(IQ packet) {
 	
 	 if (!packet.getType().equals(IQ.Type.set)) {
          throw new IllegalArgumentException(
                  "This method only accepts 'set' typed IQ stanzas as an argument.");
      }

      IQ resultIQ ;
   
      Session session = sessionManager.getSession(packet.getFrom());
      Element query = packet.getChildElement();//("query");
      String email = query.elementText("email");
String username = query.elementText("username");

if(username == null || username.equals("") || email == null || email.equals("")) {
	
	 final IQ errorgetPassword = IQ.createResultIQ(packet);
	 errorgetPassword.setError(Condition.bad_request);
	session.process(errorgetPassword);
	}

User user = null;
try {
	user = userManager.getUser(username);
	
	String newpassword = StringUtils.randomString(8);
	//StringUtils.class 
	user.setPassword(newpassword);
	
	//randomString
		try {
			EmailService.getInstance().sendMessage(username, email, "G3Chat", EmailService.getInstance().getUsername(), "reset password", "your password is:" + newpassword + ",please update your password\n Magicont Technology Inc.", null);
		
		} catch (Exception e) {
			resultIQ = IQ.createResultIQ(packet);
			resultIQ.setError(PacketError.Condition.item_not_found);
		}
		resultIQ = IQ.createResultIQ(packet);
	
} catch (UserNotFoundException e1) {
	resultIQ = IQ.createResultIQ(packet);
	resultIQ.setError(PacketError.Condition.bad_request);
}

session.process(resultIQ);
    
 }
 
开发者ID:coodeer,项目名称:g3server,代码行数:48,代码来源:IQRouter.java


注:本文中的org.jivesoftware.openfire.user.User.setPassword方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。