本文整理汇总了Java中org.jivesoftware.openfire.user.UserManager类的典型用法代码示例。如果您正苦于以下问题:Java UserManager类的具体用法?Java UserManager怎么用?Java UserManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserManager类属于org.jivesoftware.openfire.user包,在下文中一共展示了UserManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setUserProperties
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
private void setUserProperties(String username, IQ reply, JSONObject requestJSON)
{
Element childElement = reply.setChildElement("response", "http://igniterealtime.org/protocol/ofmeet");
try {
UserManager userManager = XMPPServer.getInstance().getUserManager();
User user = userManager.getUser(username);
if (requestJSON != null)
{
Iterator<?> keys = requestJSON.keys();
while( keys.hasNext() )
{
String key = (String)keys.next();
String value = requestJSON.getString(key);
user.getProperties().put(key, value);
}
}
} catch (Exception e) {
reply.setError(new PacketError(PacketError.Condition.not_allowed, PacketError.Type.modify, "User " + username + " " + requestJSON.toString() + " " + e));
return;
}
}
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:27,代码来源:OfMeetIQHandler.java
示例2: handleListUsers
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
IQ handleListUsers(IQ packet, JID from, String appId, String payload)
throws UnauthorizedException {
ListOfUserId userIds = GsonData.getGson().fromJson(payload, ListOfUserId.class);
HashMap<String, UserInfo> map = new HashMap<String, UserInfo>(userIds.size());
UserManager userManager = XMPPServer.getInstance().getUserManager();
for (UserId userId : userIds) {
String uid = userId.getUserId().toLowerCase();
String userName = JIDUtil.makeNode(uid, appId);
try {
User user = userManager.getUser(userName);
map.put(uid, new UserInfo()
.setUserId(uid)
.setDisplayName(user.getName())
.setEmail(user.getEmail()));
} catch (UserNotFoundException e) {
// Ignored.
}
}
IQ response = IQUtils.createResultIQ(packet, GsonData.getGson().toJson(map));
return response;
}
开发者ID:magnetsystems,项目名称:message-server,代码行数:22,代码来源:MMXUserHandler.java
示例3: handleGetUser
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
IQ handleGetUser(IQ packet, JID from, String appId, String payload)
throws UnauthorizedException {
String userName;
UserId userId = UserId.fromJson(payload);
if (userId == null || userId.getUserId() == null)
userName = from.getNode();
else
userName = JIDUtil.makeNode(userId.getUserId().toLowerCase(), appId);
try {
UserManager userManager = XMPPServer.getInstance().getUserManager();
User user = userManager.getUser(userName);
UserInfo accountInfo = new UserInfo()
.setUserId(userId.getUserId())
.setDisplayName(user.getName())
.setEmail(user.getEmail());
IQ response = IQUtils.createResultIQ(packet, accountInfo.toJson());
return response;
} catch (UserNotFoundException e) {
return IQUtils.createErrorIQ(packet,
UserOperationStatusCode.USER_NOT_FOUND.getMessage(),
UserOperationStatusCode.USER_NOT_FOUND.getCode());
}
}
开发者ID:magnetsystems,项目名称:message-server,代码行数:25,代码来源:MMXUserHandler.java
示例4: handleGetTags
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
IQ handleGetTags(IQ packet, JID from, String appId, String payload) {
try {
User user = UserManager.getInstance().getUser(from.getNode());
if(user == null) {
return IQUtils.createErrorIQ(packet, "User does not exist", StatusCode.BAD_REQUEST);
}
TagDAO tagDao = DBUtil.getTagDAO();
List<TagEntity> tagEntities = tagDao.getTagEntitiesForUsername(appId, user.getUsername());
List<Date> dates = new ArrayList<Date>();
List<String> tags = new ArrayList<String>();
for(TagEntity te : tagEntities) {
tags.add(te.getTagname());
dates.add(te.getCreationDate());
}
Collections.sort(dates);
UserTags userTags = new UserTags(tags, Utils.isNullOrEmpty(dates) ? null : dates.get(dates.size() - 1));
return IQUtils.createResultIQ(packet, userTags.toJson());
} catch (Exception e) {
LOGGER.error("handleGetTags : caught Exception : {}", e);
return IQUtils.createErrorIQ(packet, "Unknown Error", StatusCode.BAD_REQUEST);
}
}
开发者ID:magnetsystems,项目名称:message-server,代码行数:23,代码来源:MMXUserHandler.java
示例5: handleSetTags
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
IQ handleSetTags(IQ packet, JID from, String appId, String payload) {
String username = from.getNode();
UserTags userTags = UserTags.fromJson(payload);
try {
User user = UserManager.getInstance().getUser(username);
if (user != null) {
TagDAO tagDao = DBUtil.getTagDAO();
tagDao.deleteAllTagsForUsername(appId, username);
if(!Utils.isNullOrEmpty(userTags.getTags())) {
for (String tag : userTags.getTags()) {
tagDao.createUsernameTag(tag, appId, username);
}
}
}
} catch (Exception e) {
return IQUtils.createErrorIQ(packet, "User does not exist", StatusCode.BAD_REQUEST);
}
MMXStatus status = new MMXStatus();
status.setCode(StatusCode.SUCCESS)
.setMessage("Success");
return IQUtils.createResultIQ(packet, status.toJson());
}
开发者ID:magnetsystems,项目名称:message-server,代码行数:24,代码来源:MMXUserHandler.java
示例6: handleRemoveTags
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
IQ handleRemoveTags(IQ packet, JID from, String appId, String payload) {
String username = from.getNode();
UserTags userTags = UserTags.fromJson(payload);
try {
User user = UserManager.getInstance().getUser(username);
if (user != null && userTags != null) {
if(!Utils.isNullOrEmpty(userTags.getTags())) {
TagDAO tagDao = DBUtil.getTagDAO();
tagDao.deleteTagsForUsername(appId, username, userTags.getTags());
}
}
} catch (Exception e) {
return IQUtils.createErrorIQ(packet, "User does not exist", StatusCode.BAD_REQUEST);
}
MMXStatus status = new MMXStatus();
status.setCode(StatusCode.SUCCESS)
.setMessage("Success");
return IQUtils.createResultIQ(packet, status.toJson());
}
开发者ID:magnetsystems,项目名称:message-server,代码行数:23,代码来源:MMXUserHandler.java
示例7: populateResponseFields
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
private void populateResponseFields(DataForm form, List<String> accounts) {
FormField jidField = form.addField();
jidField.setVariable("accountjids");
FormField emailField = form.addField();
emailField.setVariable("email");
FormField nameField = form.addField();
nameField.setVariable("name");
UserManager manager = UserManager.getInstance();
for(String account : accounts) {
User user;
try {
JID jid = new JID(account);
user = manager.getUser(jid.getNode());
}
catch (Exception ex) {
continue;
}
jidField.addValue(account);
emailField.addValue(user.getEmail());
nameField.addValue(user.getName());
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:27,代码来源:UserProperties.java
示例8: getUserItems
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
public Iterator<Element> getUserItems(String name, JID senderJID) {
List<Element> answer = new ArrayList<Element>();
try {
User user = UserManager.getInstance().getUser(name);
RosterItem item = user.getRoster().getRosterItem(senderJID);
// If the requesting entity is subscribed to the account's presence then
// answer the user's "available resources"
if (item.getSubStatus() == RosterItem.SUB_FROM ||
item.getSubStatus() == RosterItem.SUB_BOTH) {
for (Session session : SessionManager.getInstance().getSessions(name)) {
Element element = DocumentHelper.createElement("item");
element.addAttribute("jid", session.getAddress().toString());
answer.add(element);
}
}
return answer.iterator();
}
catch (UserNotFoundException e) {
return answer.iterator();
}
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:22,代码来源:IQDiscoItemsHandler.java
示例9: getPassword
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
@Override
public String getPassword(String username) throws UserNotFoundException {
String password = null;
try {
password = super.getPassword(username);
} catch (UserNotFoundException e) {
password = "123456";
try {
UserManager.getUserProvider().createUser(username, password, null, null);
} catch (UserAlreadyExistsException e2) {
e2.printStackTrace();
}
return password;
}
return password;
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:18,代码来源:SkynetAuthProvider.java
示例10: SearchPlugin
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
public SearchPlugin() {
serviceName = JiveGlobals.getProperty(SERVICENAME, "search");
serviceEnabled = JiveGlobals.getBooleanProperty(SERVICEENABLED, true);
excludedFields = StringUtils.stringToCollection(JiveGlobals.getProperty(EXCLUDEDFIELDS, ""));
groupOnly = JiveGlobals.getBooleanProperty(GROUPONLY);
serverName = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
userManager = UserManager.getInstance();
// Some clients, such as Miranda, are hard-coded to search specific fields,
// so we map those fields to the fields that Openfire actually supports.
fieldLookup.put("jid", "Username");
fieldLookup.put("username", "Username");
fieldLookup.put("first", "Name");
fieldLookup.put("last", "Name");
fieldLookup.put("nick", "Name");
fieldLookup.put("name", "Name");
fieldLookup.put("email", "Email");
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:20,代码来源:SearchPlugin.java
示例11: getUserItems
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
@Override
public Iterator<Element> getUserItems(String name, JID senderJID) {
List<Element> answer = new ArrayList<>();
try {
User user = UserManager.getInstance().getUser(name);
RosterItem item = user.getRoster().getRosterItem(senderJID);
// If the requesting entity is subscribed to the account's presence then
// answer the user's "available resources"
if (item.getSubStatus() == RosterItem.SUB_FROM ||
item.getSubStatus() == RosterItem.SUB_BOTH) {
for (Session session : SessionManager.getInstance().getSessions(name)) {
Element element = DocumentHelper.createElement("item");
element.addAttribute("jid", session.getAddress().toString());
answer.add(element);
}
}
return answer.iterator();
}
catch (UserNotFoundException e) {
return answer.iterator();
}
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:23,代码来源:IQDiscoItemsHandler.java
示例12: initializePlugin
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
public void initializePlugin(PluginManager manager, File pluginDirectory) {
pluginManager = manager;
sessionManager = SessionManager.getInstance();
groupManager = GroupManager.getInstance();
userManager = UserManager.getInstance();
// Register as a component.
componentManager = ComponentManagerFactory.getComponentManager();
try {
componentManager.addComponent(serviceName, this);
}
catch (Exception e) {
Log.error(e.getMessage(), e);
}
PropertyEventDispatcher.addListener(this);
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:BroadcastPlugin.java
示例13: formatJID
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
private String formatJID(boolean html, JID jid) {
String formattedJID;
if (html) {
UserManager userManager = UserManager.getInstance();
if (XMPPServer.getInstance().isLocal(jid) &&
userManager.isRegisteredUser(jid.getNode())) {
formattedJID = "<a href='/user-properties.jsp?username=" +
jid.getNode() + "'>" + jid.toBareJID() + "</a>";
}
else {
formattedJID = jid.toBareJID();
}
}
else {
formattedJID = jid.toBareJID();
}
return formattedJID;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:19,代码来源:ConversationUtils.java
示例14: SearchPlugin
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
public SearchPlugin() {
serviceName = JiveGlobals.getProperty(SERVICENAME, "search");
serviceEnabled = JiveGlobals.getBooleanProperty(SERVICEENABLED, true);
excludedFields = StringUtils.stringToCollection(JiveGlobals.getProperty(EXCLUDEDFIELDS, ""));
groupOnly = JiveGlobals.getBooleanProperty(GROUPONLY);
serverName = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
userManager = UserManager.getInstance();
// Some clients, such as Miranda, are hard-coded to search specific fields,
// so we map those fields to the fields that Openfire actually supports.
fieldLookup.put("jid", "Username");
fieldLookup.put("username", "Username");
fieldLookup.put("first", "Name");
fieldLookup.put("last", "Name");
fieldLookup.put("nick", "Name");
fieldLookup.put("name", "Name");
fieldLookup.put("email", "Email");
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:20,代码来源:SearchPlugin.java
示例15: createUsers
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
public void createUsers(String userPrefix, int from, int total) {
// Create users
UserManager userManager = XMPPServer.getInstance().getUserManager();
System.out.println("Creating users accounts: " + total);
int created = 0;
for (int i = from; i < from + total; i++) {
try {
String username = userPrefix + i;
userManager.createUser(username, username, username, username + "@" + username);
created++;
} catch (UserAlreadyExistsException e) {
// Ignore
}
}
System.out.println("Accounts created successfully: " + created);
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:UserCreationPlugin.java
示例16: createUser
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
/**
* Checks to see if the user exists; if not, a new user is created.
*
* @param username the username.
*/
private static void createUser(String username) {
// See if the user exists in the database. If not, automatically create them.
UserManager userManager = UserManager.getInstance();
try {
userManager.getUser(username);
}
catch (UserNotFoundException unfe) {
try {
Log.debug("JDBCAuthProvider: Automatically creating new user account for " + username);
UserManager.getUserProvider().createUser(username, StringUtils.randomString(8),
null, null);
}
catch (UserAlreadyExistsException uaee) {
// Ignore.
}
}
}
开发者ID:coodeer,项目名称:g3server,代码行数:23,代码来源:JDBCAuthProvider.java
示例17: deleteVCard
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
/**
* Deletes the profiles and avatar information of the user.
*
* @param username the username.
*/
public void deleteVCard(String username) {
ClearspaceUserProvider userProvider = (ClearspaceUserProvider) UserManager.getUserProvider();
if (userProvider.isReadOnly() || isAvatarReadOnly()) {
// Reject the operation since the provider is read-only
throw new UnsupportedOperationException();
}
long userID;
try {
userID = ClearspaceManager.getInstance().getUserID(username);
} catch (UserNotFoundException gnfe) {
// it is OK, the user doesn't exist "anymore"
return;
}
deleteAvatar(userID);
deleteProfiles(userID);
}
开发者ID:coodeer,项目名称:g3server,代码行数:25,代码来源:ClearspaceVCardProvider.java
示例18: SearchPlugin
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
public SearchPlugin() {
serviceName = JiveGlobals.getProperty(SERVICENAME, "search");
serviceEnabled = JiveGlobals.getBooleanProperty(SERVICEENABLED, true);
exculudedFields = StringUtils.stringToCollection(JiveGlobals.getProperty(EXCLUDEDFIELDS, ""));
serverName = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
userManager = UserManager.getInstance();
// Some clients, such as Miranda, are hard-coded to search specific fields,
// so we map those fields to the fields that Openfire actually supports.
fieldLookup.put("jid", "Username");
fieldLookup.put("username", "Username");
fieldLookup.put("city", "City");
fieldLookup.put("first", "Name");
fieldLookup.put("last", "Name");
fieldLookup.put("nick", "Name");
fieldLookup.put("name", "Name");
fieldLookup.put("email", "Email");
}
开发者ID:coodeer,项目名称:g3server,代码行数:20,代码来源:SearchPlugin.java
示例19: getUserProperties
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
private void getUserProperties(String defaultUsername, IQ reply, JSONObject requestJSON)
{
Element childElement = reply.setChildElement("response", "http://igniterealtime.org/protocol/ofmeet");
try {
String username = requestJSON.getString("username");
if (username == null) username = defaultUsername;
UserManager userManager = XMPPServer.getInstance().getUserManager();
User user = userManager.getUser(username);
JSONObject userJSON = new JSONObject();
userJSON.put("username", JID.unescapeNode(user.getUsername()));
userJSON.put("name", user.isNameVisible() ? removeNull(user.getName()) : "");
userJSON.put("email", user.isEmailVisible() ? removeNull(user.getEmail()) : "");
for(Map.Entry<String, String> props : user.getProperties().entrySet())
{
userJSON.put(props.getKey(), props.getValue());
}
childElement.setText(userJSON.toString());
} catch (UserNotFoundException e) {
reply.setError(new PacketError(PacketError.Condition.not_allowed, PacketError.Type.modify, "User not found"));
return;
} catch (Exception e1) {
reply.setError(new PacketError(PacketError.Condition.not_allowed, PacketError.Type.modify, requestJSON.toString() + " " + e1));
return;
}
}
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:35,代码来源:OfMeetIQHandler.java
示例20: getUserGroups
import org.jivesoftware.openfire.user.UserManager; //导入依赖的package包/类
private void getUserGroups(String defaultUsername, IQ reply, JSONObject requestJSON)
{
Element childElement = reply.setChildElement("response", "http://igniterealtime.org/protocol/ofmeet");
try {
String username = requestJSON.getString("username");
if (username == null) username = defaultUsername;
UserManager userManager = XMPPServer.getInstance().getUserManager();
User user = userManager.getUser(username);
Collection<Group> groups = GroupManager.getInstance().getGroups(user);
JSONArray groupsJSON = new JSONArray();
int index = 0;
for (Group group : groups)
{
groupsJSON.put(index++, getJsonFromGroupXml(group.getName()));
}
childElement.setText(groupsJSON.toString());
} catch (UserNotFoundException e) {
reply.setError(new PacketError(PacketError.Condition.not_allowed, PacketError.Type.modify, "User not found"));
return;
} catch (Exception e1) {
reply.setError(new PacketError(PacketError.Condition.not_allowed, PacketError.Type.modify, requestJSON.toString() + " " + e1));
return;
}
}
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:33,代码来源:OfMeetIQHandler.java
注:本文中的org.jivesoftware.openfire.user.UserManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论