本文整理汇总了Java中org.jivesoftware.openfire.user.UserManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java UserManager.getInstance方法的具体用法?Java UserManager.getInstance怎么用?Java UserManager.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.openfire.user.UserManager
的用法示例。
在下文中一共展示了UserManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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");
}
示例3: 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;
}
示例4: setUp
import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
URL url = this.getClass().getResource("/test-openfire.xml");
File f = new File(url.getFile());
JiveGlobals.setConfigName(f.getName());
JiveGlobals.setHomeDirectory(f.getParent());
JiveGlobals.setProperty("provider.user.className",
"org.jivesoftware.openfire.plugin.TestUserProvider");
offlineMessagesStore = new TestOfflineMessageStore();
vCardManager = new TestVCardManager();
privateStorage = null;
userManager = UserManager.getInstance();
rosterItemProvider = new TestRosterItemProvider();
//Empty users
List<User> l = new ArrayList<>(userManager.getUsers());
for (User user : l ) {
userManager.deleteUser(user);
}
}
示例5: 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");
}
示例6: 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");
}
示例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());
}
}
示例8: 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.
}
}
}
示例9: LdapGroupProvider
import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
/**
* Constructs a new LDAP group provider.
*/
public LdapGroupProvider() {
manager = LdapManager.getInstance();
userManager = UserManager.getInstance();
standardAttributes = new String[3];
standardAttributes[0] = manager.getGroupNameField();
standardAttributes[1] = manager.getGroupDescriptionField();
standardAttributes[2] = manager.getGroupMemberField();
}
示例10: Xep227Exporter
import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
/**
*/
public Xep227Exporter() {
offlineMessagesStore = XMPPServer.getInstance()
.getOfflineMessageStore();
serverName = XMPPServer.getInstance().getServerInfo().getXMPPDomain();
//TODO not yet implemented
//privateStorage = XMPPServer.getInstance().getPrivateStorage();
vCardManager = VCardManager.getInstance();
userManager = UserManager.getInstance();
rosterItemProvider = RosterManager.getRosterItemProvider();
}
示例11: setUp
import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
URL url = this.getClass().getResource("/test-openfire.xml");
File f = new File(url.getFile());
JiveGlobals.setConfigName(f.getName());
JiveGlobals.setHomeDirectory(f.getParent());
JiveGlobals.setProperty("provider.user.className",
"org.jivesoftware.openfire.plugin.TestUserProvider");
userManager = UserManager.getInstance();
rosterItemProvider = new TestRosterItemProvider();
}
示例12: executeGet
import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
public void executeGet(IQ packet, Workgroup workgroup) {
IQ reply = IQ.createResultIQ(packet);
// Retrieve the sound settings.
String authRequired = workgroup.getProperties().getProperty("authRequired");
Element returnPacket = reply.setChildElement("workgroup-properties",
"http://jivesoftware.com/protocol/workgroup");
if (ModelUtil.hasLength(authRequired)) {
returnPacket.addElement("authRequired").setText(authRequired);
}
else {
returnPacket.addElement("authRequired").setText("false");
}
Element iq = packet.getChildElement();
Attribute attr = iq.attribute("jid");
if (attr != null && ModelUtil.hasLength(iq.attribute("jid").getText())) {
String jid = iq.attribute("jid").getText();
UserManager userManager = UserManager.getInstance();
try {
User user = userManager.getUser(new JID(jid).getNode());
String email = user.getEmail();
String fullName = user.getName();
returnPacket.addElement("email").setText(email);
returnPacket.addElement("name").setText(fullName);
}
catch (UserNotFoundException e) {
Log.error(e.getMessage(), e);
}
}
workgroup.send(reply);
}
示例13: initializePlugin
import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
public void initializePlugin(PluginManager manager, File pluginDirectory) {
Log.info("ServerInfo - Starting plugin.");
Log.debug("ServerInfo - Starting plugin.");
pluginManager = manager;
sessionManager = SessionManager.getInstance();
String serverInfoPort = JiveGlobals.getProperty(SERVERINFOPORT, "4455");
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);
Log.info("ServerInfo - Starting bind on port " + serverInfoPort + ".");
Log.debug("ServerInfo - Starting bind on port " + serverInfoPort + ".");
ofd_srv.startServer();
}
示例14: initializePlugin
import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
@Override
public void initializePlugin(PluginManager manager, File pluginDirectory) {
System.out.println("initialize BroadcastServicePlugin");
pluginManager = manager;
server = XMPPServer.getInstance();
sessionManager = SessionManager.getInstance();
groupManager = GroupManager.getInstance();
userManager = UserManager.getInstance();
presenceManager = server.getPresenceManager();
secret = JiveGlobals.getProperty("plugin.broadcastservice.secret", "");
// If no secret key has been assigned to the broadcast service yet,
// assign a
// random one.
if (secret.equals("")) {
secret = StringUtils.randomString(8);
setSecret(secret);
}
// See if the service is enabled or not.
enabled = JiveGlobals.getBooleanProperty("plugin.broadcastservice.enabled", false);
// Register as a component.
componentManager = ComponentManagerFactory.getComponentManager();
try {
componentManager.addComponent(serviceName, this);
} catch (Exception e) {
Log.error(e.getMessage(), e);
}
// Listen to system property events
PropertyEventDispatcher.addListener(this);
}
示例15: authenticate
import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
@Override
public void authenticate(String username, String password) throws UnauthorizedException {
if (username.contains("@")) {
// Check that the specified domain matches the server's domain
int index = username.indexOf("@");
String domain = username.substring(index + 1);
if (domain.equals(XMPPServer.getInstance().getServerInfo().getXMPPDomain())) {
username = username.substring(0, index);
} else {
// Unknown domain. Return authentication failed.
throw new UnauthorizedException();
}
}
try {
// Some native authentication mechanisms appear to not handle high load
// very well. Therefore, synchronize access to Shaj to throttle auth checks.
synchronized (this) {
if (!Shaj.checkPassword(domain, username, password)) {
throw new UnauthorizedException();
}
}
}
catch (UnauthorizedException ue) {
throw ue;
}
catch (Exception e) {
throw new UnauthorizedException(e);
}
// 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("Automatically creating new user account for " + username);
// Create user; use a random password for better safety in the future.
// Note that we have to go to the user provider directly -- because the
// provider is read-only, UserManager will usually deny access to createUser.
UserProvider provider = UserManager.getUserProvider();
if (!(provider instanceof NativeUserProvider)) {
Log.error("Error: not using NativeUserProvider so authentication with " +
"NativeAuthProvider will likely fail. Using: " +
provider.getClass().getName());
}
UserManager.getUserProvider().createUser(username, StringUtils.randomString(8),
null, null);
}
catch (UserAlreadyExistsException uaee) {
// Ignore.
}
}
}