本文整理汇总了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);
}
}
示例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;
}
示例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");
}
示例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());
}
}
示例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");
}
示例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);
}