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


Java UserManager.getUser方法代码示例

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


在下文中一共展示了UserManager.getUser方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例5: 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.
 */
// @VisibleForTesting
protected 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:igniterealtime,项目名称:Openfire,代码行数:24,代码来源:JDBCAuthProvider.java

示例6: 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

示例7: 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

示例8: 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

示例9: handleUpdateUser

import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
IQ handleUpdateUser(IQ packet, JID from, String appId, String payload)
    throws UnauthorizedException {
  UserInfo request = UserInfo.fromJson(payload);
  String userName = from.getNode();
  
  try {
    UserManager userManager = XMPPServer.getInstance().getUserManager();
    User user = userManager.getUser(userName);
    if (user == null) {
      throw new UserNotFoundException();
    }
    if (request.getEmail() != null) {
      user.setEmail(request.getEmail());
    }
    if (request.getDisplayName() != null) {
      user.setName(request.getDisplayName());
    }
  } catch (UserNotFoundException e) {
    return IQUtils.createErrorIQ(packet,
          UserOperationStatusCode.USER_NOT_FOUND.getMessage(),
          UserOperationStatusCode.USER_NOT_FOUND.getCode());
  }

  MMXStatus userResp = new MMXStatus();
  userResp.setCode(UserOperationStatusCode.USER_UPDATED.getCode());
  userResp.setMessage(UserOperationStatusCode.USER_UPDATED.getMessage());
  IQ response = IQUtils.createResultIQ(packet, userResp.toJson());
  return response;
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:30,代码来源:MMXUserHandler.java

示例10: 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);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:37,代码来源:WorkgroupPropertiesProvider.java

示例11: processMeeting

import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
public static void processMeeting(JSONObject meeting, String username, String videourl)
{
    Log.info("OfMeet Plugin - processMeeting " + username + " " + meeting);

    try {
        UserManager userManager = XMPPServer.getInstance().getUserManager();
        User user = userManager.getUser(username);
        Date start = new Date(meeting.getLong("startTime"));
        Date end = new Date(meeting.getLong("endTime"));
        String name = user.getName();
        String email = user.getEmail();
        String description = meeting.getString("description");
        String title = meeting.getString("title");
        String room = meeting.getString("room");
        //String videourl = "https://" + XMPPServer.getInstance().getServerInfo().getHostname() + ":" + JiveGlobals.getProperty("httpbind.port.secure", "7443") + "/ofmeet/?r=" + room;
        String audiourl = videourl + "&novideo=true";
        String template = JiveGlobals.getProperty("ofmeet.email.template", "Dear [name],\n\nYou have an online meeting from [start] to [end]\n\n[description]\n\nTo join, please click\n[videourl]\nFor audio only with no webcan, please click\n[audiourl]\n\nAdministrator - [domain]");

        HashMap variables = new HashMap<String, String>();

        if (email != null)
        {
            variables.put("name", name);
            variables.put("email", email);
            variables.put("start", start.toString());
            variables.put("end", end.toString());
            variables.put("description", description);
            variables.put("title", title);
            variables.put("room", room);
            variables.put("videourl", videourl);
            variables.put("audiourl", audiourl);
            variables.put("domain", XMPPServer.getInstance().getServerInfo().getXMPPDomain());

            sendEmail(name, email, title, replaceTokens(template, variables), null);
            SecurityAuditManager.getInstance().logEvent(user.getUsername(), "sent email - " + title, description);
        }
    }
    catch (Exception e) {
        Log.error("processMeeting error", e);
    }
}
 
开发者ID:igniterealtime,项目名称:ofmeet-openfire-plugin,代码行数:42,代码来源:MeetingPlanner.java

示例12: 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.
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:55,代码来源:NativeAuthProvider.java

示例13: sendEmail

import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
public void sendEmail() {
    ByteArrayOutputStream outputStream = null;
    try {
        String host = JiveGlobals.getProperty("mail.smtp.host", "localhost");
        String port = JiveGlobals.getProperty("mail.smtp.port", "25");
        String username = JiveGlobals.getProperty("mail.smtp.username");
        String password = JiveGlobals.getProperty("mail.smtp.password");
        String debugEnabled = JiveGlobals.getProperty("mail.debug");
        boolean sslEnabled = JiveGlobals.getBooleanProperty("mail.smtp.ssl", true);

        Properties props = new Properties();
        props.put("mail.smtp.host", host);
        props.put("mail.smtp.auth", port);
        props.setProperty("mail.smtp.sendpartial", "true");
        props.setProperty("mail.debug", debugEnabled);

        if (sslEnabled) {
            // Register with security provider.
            Security.setProperty("ssl.SocketFactory.provider", SSL_FACTORY);
            props.setProperty("mail.smtp.socketFactory.class", SSL_FACTORY);
            props.setProperty("mail.smtp.socketFactory.fallback", "true");
        }

        if (username != null) {
            props.put("mail.smtp.auth", "true");
        }

        Session session = Session.getInstance(props);
        outputStream = new ByteArrayOutputStream();
        createPdfAttachment(outputStream);
        byte[] bytes = outputStream.toByteArray();
        ByteArrayDataSource dataSource = new ByteArrayDataSource(bytes, "application/pdf");
        MimeBodyPart pdfBodyPart = new MimeBodyPart();
        pdfBodyPart.setDataHandler(new DataHandler(dataSource));
        pdfBodyPart.setFileName("ResultSummary.pdf");
        MimeMultipart multipart= new MimeMultipart();
        multipart.addBodyPart(pdfBodyPart);
        MimeMessage msg = new MimeMessage(session);

        DefaultAdminProvider defaultAdminProvider= new DefaultAdminProvider();
        java.util.List<JID> adminList=defaultAdminProvider.getAdmins();
        java.util.List<String> adminListEmails=new ArrayList<String>();

        UserManager manager = UserManager.getInstance();
        Log.info("Number of Admins " +adminList.size());
        for(int i = 0; i < adminList.size(); i++) {
            User user;
            try {
                user = manager.getUser(adminList.get(i).getNode().toString());
                Log.info("Admin Emails: " +user.getEmail());
                adminListEmails.add(user.getEmail());
            }
            catch (Exception ex) {
                continue;
            }
        }

       // java.util.List<String> recipientsList=Arrays.asList("", "", "");
        InternetAddress[] recipients = new InternetAddress[adminListEmails.size()];
        for (int i = 0; i < adminListEmails.size(); i++) {
            recipients[i] = new InternetAddress(adminListEmails.get(i).toString());
        }
        msg.setFrom(new InternetAddress("[email protected]", "Openfire Admin"));
        msg.setRecipients(javax.mail.Message.RecipientType.TO,recipients);
        msg.setSubject("MONITORING REPORT - " + new SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(new Date()));
        msg.setContent(multipart);

        if (username != null)
        {
            URLName url = new URLName("smtp", host, Integer.parseInt(port), "", username, password);
            Transport transport = new com.sun.mail.smtp.SMTPTransport(session, url);
            transport.connect(host, Integer.parseInt(port), username, password);
            transport.sendMessage(msg, msg.getRecipients(MimeMessage.RecipientType.TO));

       } else Transport.send(msg);

    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("Could not send email");
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:82,代码来源:EmailSenderUtility.java

示例14: authenticate

import org.jivesoftware.openfire.user.UserManager; //导入方法依赖的package包/类
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.
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:54,代码来源:NativeAuthProvider.java


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