/** * Returns the number of request made to a workgroup between specified dates. * * @param workgroupName the workgroup to search * @param startDate the time to begin the search from. * @param endDate the time to end the search. * @return the total number of requests */ public static int getNumberOfRequestsForWorkgroup( String workgroupName, Date startDate, Date endDate) { Workgroup workgroup = getWorkgroup(workgroupName); if (workgroup == null) { return 0; } int count = 0; Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(WORKGROUP_REQUEST_COUNT); pstmt.setLong(1, workgroup.getID()); pstmt.setString(2, StringUtils.dateToMillis(startDate)); pstmt.setString(3, StringUtils.dateToMillis(endDate)); rs = pstmt.executeQuery(); if (rs.next()) { count = rs.getInt(1); } } catch (Exception ex) { Log.error(ex.getMessage(), ex); } finally { DbConnectionManager.closeConnection(rs, pstmt, con); } return count; }
public Collection<User> findUsers(Set<String> fields, String query) throws UnsupportedOperationException { if (fields.isEmpty()) { return Collections.emptyList(); } if (!getSearchFields().containsAll(fields)) { throw new IllegalArgumentException("Search fields " + fields + " are not valid."); } if (query == null || "".equals(query)) { return Collections.emptyList(); } // SQL LIKE queries don't map directly into a keyword/wildcard search like we want. // Therefore, we do a best approximiation by replacing '*' with '%' and then // surrounding the whole query with two '%'. This will return more data than desired, // but is better than returning less data than desired. query = "%" + query.replace('*', '%') + "%"; if (query.endsWith("%%")) { query = query.substring(0, query.length() - 1); } List<String> usernames = new ArrayList<String>(50); Connection con = null; Statement stmt = null; ResultSet rs = null; try { con = DbConnectionManager.getConnection(); stmt = con.createStatement(); StringBuilder sql = new StringBuilder(); sql.append("SELECT username FROM jiveUser WHERE"); boolean first = true; if (fields.contains("Username")) { sql.append(" username LIKE '").append(StringUtils.escapeForSQL(query)).append("'"); first = false; } if (fields.contains("Name")) { if (!first) { sql.append(" AND"); } sql.append(" name LIKE '").append(StringUtils.escapeForSQL(query)).append("'"); first = false; } if (fields.contains("Email")) { if (!first) { sql.append(" AND"); } sql.append(" email LIKE '").append(StringUtils.escapeForSQL(query)).append("'"); } rs = stmt.executeQuery(sql.toString()); while (rs.next()) { usernames.add(rs.getString(1)); } } catch (SQLException e) { Log.error(e); } finally { DbConnectionManager.closeConnection(rs, stmt, con); } return new UserCollection(usernames.toArray(new String[usernames.size()])); }
public void setEmail(String email) { if (UserManager.getUserProvider().isReadOnly()) { throw new UnsupportedOperationException("User provider is read-only."); } if (email != null && email.matches("\\s*")) { email = null; } if (UserManager.getUserProvider().isEmailRequired() && !StringUtils.isValidEmailAddress(email)) { throw new IllegalArgumentException("User provider requires email address."); } try { String originalEmail = this.email; UserManager.getUserProvider().setEmail(username, email); this.email = email; // Fire event. Map<String, Object> params = new HashMap<String, Object>(); params.put("type", "emailModified"); params.put("originalValue", originalEmail); UserEventDispatcher.dispatchEvent(this, UserEventDispatcher.EventType.user_modified, params); } catch (UserNotFoundException unfe) { Log.error(unfe.getMessage(), unfe); } }
/** * Retrieves the last n conversations from the system that were created after the given * conversationID. * * @param count the count of conversations to return. * @param mostRecentConversationID the last conversationID that has been retrieved. * @return a List of Map objects. */ public List<Map<String, Long>> getNLatestConversations(int count, long mostRecentConversationID) { // TODO Fix plugin name 2 lines below and missing classes List<Map<String, Long>> cons = new ArrayList<Map<String, Long>>(); MonitoringPlugin plugin = (MonitoringPlugin) XMPPServer.getInstance().getPluginManager().getPlugin(MonitoringConstants.NAME); ConversationManager conversationManager = (ConversationManager) plugin.getModule(ConversationManager.class); Collection<Conversation> conversations = conversationManager.getConversations(); List<Conversation> lConversations = Arrays.asList(conversations.toArray(new Conversation[conversations.size()])); Collections.sort(lConversations, conversationComparator); int counter = 0; for (Iterator<Conversation> i = lConversations.iterator(); i.hasNext() && counter < count; ) { Conversation con = i.next(); if (mostRecentConversationID == con.getConversationID()) { break; } else { Map mCon = new HashMap(); mCon.put("conversationid", con.getConversationID()); String users[]; int usersIdx = 0; if (con.getRoom() == null) { users = new String[con.getParticipants().size()]; for (JID jid : con.getParticipants()) { String identifier = jid.toBareJID(); try { identifier = UserNameManager.getUserName(jid, jid.toBareJID()); } catch (UserNotFoundException e) { // Ignore } users[usersIdx++] = StringUtils.abbreviate(identifier, 20); } } else { users = new String[2]; users[0] = LocaleUtils.getLocalizedString( "dashboard.group_conversation", MonitoringConstants.NAME); try { users[1] = "(<i>" + LocaleUtils.getLocalizedString("muc.room.summary.room") + ": <a href='../../muc-room-occupants.jsp?roomName=" + URLEncoder.encode(con.getRoom().getNode(), "UTF-8") + "'>" + con.getRoom().getNode() + "</a></i>)"; } catch (UnsupportedEncodingException e) { Log.error(e.getMessage(), e); } } mCon.put("users", users); mCon.put("lastactivity", formatTimeLong(con.getLastActivity())); mCon.put("messages", con.getMessageCount()); cons.add(0, mCon); counter++; } } return cons; }
/** * Deletes the specified offline message in the store for a user. The way to identify the message * to delete is based on the creationDate and username. * * @param username the username of the user who's message is going to be deleted. * @param creationDate the date when the offline message was stored in the database. */ public void deleteMessage(String username, Date creationDate) { Connection con = null; PreparedStatement pstmt = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(DELETE_OFFLINE_MESSAGE); pstmt.setString(1, username); pstmt.setString(2, StringUtils.dateToMillis(creationDate)); pstmt.executeUpdate(); // Force a refresh for next call to getSize(username), // it's easier than loading the message to be deleted just // to update the cache. removeUsernameFromSizeCache(username); } catch (Exception e) { Log.error( "Error deleting offline messages of username: "******" creationDate: " + creationDate, e); } finally { DbConnectionManager.closeConnection(pstmt, con); } }
/** * Login to the XMPP server and establish a non-anonymous user session using the given username * and resource. When <tt>createIfNotExist</tt> is <tt>true</tt>, a new user with the username * will be created and stored in the database if it does not exist. When <tt>false</tt>, and the * user does not exist, the method will not attempt the login. Whenever there's an error, the bot * will not login. * * @param username Username to login with. * @param resource The resource the user will bind to. * @param createIfNotExist When specified as <tt>true</tt>, a new user will be created and stored * in the database if it does not exist. * @throws SessionAlreadyExistsException If the bot's session already exists. * @throws UserNotFoundException If it fails to create the user. */ public void login(String username, String resource, boolean createIfNotExist) throws SessionAlreadyExistsException, UserNotFoundException { LOGGER.debug("Bot login with username:{} with resource:{}", username, resource); if (isClosed()) throw new SessionAlreadyExistsException(); JID jid = new JID( username.toLowerCase(), XMPPServer.getInstance().getServerInfo().getXMPPDomain(), resource); ClientSession oldSession = SessionManager.getInstance().getSession(jid); // Check for session conflict if (oldSession != null) { try { int count = oldSession.incrementConflictCount(); int conflictLimit = SessionManager.getInstance().getConflictKickLimit(); if (conflictLimit != SessionManager.NEVER_KICK && count > conflictLimit) { // Kick out the old connection that is conflicting with the // new one StreamError error = new StreamError(StreamError.Condition.conflict); oldSession.deliverRawText(error.toXML()); oldSession.close(); } else throw new SessionAlreadyExistsException(); } catch (Exception e) { LOGGER.error("Error during login", e); } } if (!XMPPServer.getInstance().getUserManager().isRegisteredUser(jid.getNode())) { if (createIfNotExist) { try { // Bot doesn't care of whatever password it is. XMPPServer.getInstance() .getUserManager() .createUser(jid.getNode(), StringUtils.randomString(15), null, null); } catch (UserAlreadyExistsException e) { // Ignore } } else { throw new UserNotFoundException(); } } localClientSession = SessionManager.getInstance().createClientSession(this); localClientSession.setAuthToken(new AuthToken(jid.getNode()), jid.getResource()); if (packetProcessor != null) { packetProcessor.initialize(this); initProcessor = true; } }
private static boolean doExternalAuthentication( String domain, SocketConnection connection, XMPPPacketReader reader) throws DocumentException, IOException, XmlPullParserException { StringBuilder sb = new StringBuilder(); sb.append("<auth xmlns=\"urn:ietf:params:xml:ns:xmpp-sasl\" mechanism=\"EXTERNAL\">"); sb.append(StringUtils.encodeBase64(domain)); sb.append("</auth>"); connection.deliverRawText(sb.toString()); Element response = reader.parseDocument().getRootElement(); return response != null && "success".equals(response.getName()); }
/** * Adds a message to this message store. Messages will be stored and made available for later * delivery. * * @param message the message to store. */ public void addMessage(Message message) { if (message == null) { return; } if (!shouldStoreMessage(message)) { return; } JID recipient = message.getTo(); String username = recipient.getNode(); // If the username is null (such as when an anonymous user), don't store. if (username == null || !UserManager.getInstance().isRegisteredUser(recipient)) { return; } else if (!XMPPServer.getInstance() .getServerInfo() .getXMPPDomain() .equals(recipient.getDomain())) { // Do not store messages sent to users of remote servers return; } long messageID = SequenceManager.nextID(JiveConstants.OFFLINE); // Get the message in XML format. String msgXML = message.getElement().asXML(); Connection con = null; PreparedStatement pstmt = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(INSERT_OFFLINE); pstmt.setString(1, username); pstmt.setLong(2, messageID); pstmt.setString(3, StringUtils.dateToMillis(new java.util.Date())); pstmt.setInt(4, msgXML.length()); pstmt.setString(5, msgXML); pstmt.executeUpdate(); } catch (Exception e) { Log.error(LocaleUtils.getLocalizedString("admin.error"), e); } finally { DbConnectionManager.closeConnection(pstmt, con); } // Update the cached size if it exists. if (sizeCache.containsKey(username)) { int size = sizeCache.get(username); size += msgXML.length(); sizeCache.put(username, size); } }
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. } } }
public void setCreationDate(String username, Date creationDate) throws UserNotFoundException { Connection con = null; PreparedStatement pstmt = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(UPDATE_CREATION_DATE); pstmt.setString(1, StringUtils.dateToMillis(creationDate)); pstmt.setString(2, username); pstmt.executeUpdate(); } catch (SQLException sqle) { throw new UserNotFoundException(sqle); } finally { DbConnectionManager.closeConnection(pstmt, con); } }
/** * Returns the number of canceled requests. * * @param workgroupName the workgroup to search * @param startDate the time to begin the search from. * @param endDate the time to end the search. * @return the total number of requests */ public static long getTotalWaitTimeForWorkgroup( String workgroupName, Date startDate, Date endDate) { Workgroup workgroup = null; try { workgroup = WorkgroupManager.getInstance().getWorkgroup(new JID(workgroupName)); } catch (Exception ex) { Log.error(ex.getMessage(), ex); } if (workgroup == null) { return 0; } int waitTime = 0; Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(WORKGROUP_WAIT_TIME); pstmt.setLong(1, workgroup.getID()); // Set the state the ignored requests. pstmt.setInt(2, 1); pstmt.setString(2, StringUtils.dateToMillis(startDate)); pstmt.setString(3, StringUtils.dateToMillis(endDate)); rs = pstmt.executeQuery(); rs.next(); waitTime = rs.getInt(1); } catch (Exception ex) { Log.error(ex.getMessage(), ex); } finally { DbConnectionManager.closeConnection(rs, pstmt, con); } return waitTime; }
public void setCreationDate(String username, Date creationDate) throws UserNotFoundException { if (isReadOnly()) { // Reject the operation since the provider is read-only throw new UnsupportedOperationException(); } Connection con = null; PreparedStatement pstmt = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(UPDATE_CREATION_DATE); pstmt.setString(1, StringUtils.dateToMillis(creationDate)); pstmt.setString(2, username); pstmt.executeUpdate(); } catch (SQLException sqle) { throw new UserNotFoundException(sqle); } finally { DbConnectionManager.closeConnection(pstmt, con); } }
/** * Returns the offline message of the specified user with the given creation date. The returned * message will NOT be deleted from the database. * * @param username the username of the user who's message you'd like to receive. * @param creationDate the date when the offline message was stored in the database. * @return the offline message of the specified user with the given creation stamp. */ public OfflineMessage getMessage(String username, Date creationDate) { OfflineMessage message = null; Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; SAXReader xmlReader = null; try { // Get a sax reader from the pool xmlReader = xmlReaders.take(); con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(LOAD_OFFLINE_MESSAGE); pstmt.setString(1, username); pstmt.setString(2, StringUtils.dateToMillis(creationDate)); rs = pstmt.executeQuery(); while (rs.next()) { String msgXML = rs.getString(1); message = new OfflineMessage( creationDate, xmlReader.read(new StringReader(msgXML)).getRootElement()); // Add a delayed delivery (XEP-0203) element to the message. Element delay = message.addChildElement("delay", "urn:xmpp:delay"); delay.addAttribute("from", XMPPServer.getInstance().getServerInfo().getXMPPDomain()); delay.addAttribute("stamp", XMPPDateTimeFormat.format(creationDate)); } } catch (Exception e) { Log.error( "Error retrieving offline messages of username: "******" creationDate: " + creationDate, e); } finally { // Return the sax reader to the pool if (xmlReader != null) { xmlReaders.add(xmlReader); } DbConnectionManager.closeConnection(rs, pstmt, con); } return message; }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html"); pageContext = _jspxFactory.getPageContext(this, request, response, "error.jsp", true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\n\n\n\n\n\n\n\n\n\n\n\n"); org.jivesoftware.util.WebManager webManager = null; synchronized (_jspx_page_context) { webManager = (org.jivesoftware.util.WebManager) _jspx_page_context.getAttribute("webManager", PageContext.PAGE_SCOPE); if (webManager == null) { webManager = new org.jivesoftware.util.WebManager(); _jspx_page_context.setAttribute("webManager", webManager, PageContext.PAGE_SCOPE); } } out.write('\n'); out.write('\n'); // Get parameters boolean cancel = request.getParameter("cancel") != null; String username = ParamUtils.getParameter(request, "username"); String jid = ParamUtils.getParameter(request, "jid"); String nickname = ParamUtils.getParameter(request, "nickname"); String groups = ParamUtils.getParameter(request, "groups"); Integer sub = ParamUtils.getIntParameter(request, "sub", 0); boolean save = ParamUtils.getBooleanParameter(request, "save"); // Handle a cancel if (cancel) { response.sendRedirect("user-roster.jsp?username="******"UTF-8")); return; } // Load the user's roster object Roster roster = webManager.getRosterManager().getRoster(username); // Load the roster item from the user's roster. RosterItem item = roster.getRosterItem(new JID(jid)); // Handle a roster item delete: if (save) { List<String> groupList = new ArrayList<String>(); if (groups != null) { for (String group : groups.split(",")) { groupList.add(group.trim()); } } item.setNickname(nickname); item.setGroups(groupList); item.setSubStatus(RosterItem.SubType.getTypeFromInt(sub)); // Delete the roster item roster.updateRosterItem(item); // Log the event webManager.logEvent("deleted roster item from " + username, "roster item:\njid = " + jid); // Done, so redirect response.sendRedirect( "user-roster.jsp?username="******"UTF-8") + "&editsuccess=true"); return; } out.write("\n\n<html>\n <head>\n <title>"); if (_jspx_meth_fmt_message_0(_jspx_page_context)) return; out.write( "</title>\n <meta name=\"subPageID\" content=\"user-roster\"/>\n <meta name=\"extraParams\" content=\""); out.print("username="******"UTF-8")); out.write("\"/>\n </head>\n <body>\n\n<p>\n"); // fmt:message org.apache.taglibs.standard.tag.rt.fmt.MessageTag _jspx_th_fmt_message_1 = (org.apache.taglibs.standard.tag.rt.fmt.MessageTag) _jspx_tagPool_fmt_message_key.get( org.apache.taglibs.standard.tag.rt.fmt.MessageTag.class); _jspx_th_fmt_message_1.setPageContext(_jspx_page_context); _jspx_th_fmt_message_1.setParent(null); _jspx_th_fmt_message_1.setKey("user.roster.edit.info"); int _jspx_eval_fmt_message_1 = _jspx_th_fmt_message_1.doStartTag(); if (_jspx_eval_fmt_message_1 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { if (_jspx_eval_fmt_message_1 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) { out = _jspx_page_context.pushBody(); _jspx_th_fmt_message_1.setBodyContent((javax.servlet.jsp.tagext.BodyContent) out); _jspx_th_fmt_message_1.doInitBody(); } do { out.write("\n "); // fmt:param org.apache.taglibs.standard.tag.rt.fmt.ParamTag _jspx_th_fmt_param_0 = (org.apache.taglibs.standard.tag.rt.fmt.ParamTag) _jspx_tagPool_fmt_param_value_nobody.get( org.apache.taglibs.standard.tag.rt.fmt.ParamTag.class); _jspx_th_fmt_param_0.setPageContext(_jspx_page_context); _jspx_th_fmt_param_0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_fmt_message_1); _jspx_th_fmt_param_0.setValue(StringUtils.escapeForXML(username)); int _jspx_eval_fmt_param_0 = _jspx_th_fmt_param_0.doStartTag(); if (_jspx_th_fmt_param_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _jspx_tagPool_fmt_param_value_nobody.reuse(_jspx_th_fmt_param_0); return; } _jspx_tagPool_fmt_param_value_nobody.reuse(_jspx_th_fmt_param_0); out.write('\n'); int evalDoAfterBody = _jspx_th_fmt_message_1.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); if (_jspx_eval_fmt_message_1 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) out = _jspx_page_context.popBody(); } if (_jspx_th_fmt_message_1.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _jspx_tagPool_fmt_message_key.reuse(_jspx_th_fmt_message_1); return; } _jspx_tagPool_fmt_message_key.reuse(_jspx_th_fmt_message_1); out.write("\n</p>\n\n<fieldset>\n <legend>"); if (_jspx_meth_fmt_message_2(_jspx_page_context)) return; out.write( "</legend>\n <div>\n <table cellpadding=\"3\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n <tbody>\n <tr>\n <td class=\"c1\">\n "); if (_jspx_meth_fmt_message_3(_jspx_page_context)) return; out.write(":\n </td>\n <td>\n "); out.print(StringUtils.escapeHTMLTags(jid)); out.write( "\n </td>\n </tr>\n <tr>\n <td class=\"c1\">\n "); if (_jspx_meth_fmt_message_4(_jspx_page_context)) return; out.write(":\n </td>\n <td>\n "); out.print(StringUtils.escapeHTMLTags(item.getNickname())); out.write( "\n </td>\n </tr>\n <tr>\n <td class=\"c1\">\n "); if (_jspx_meth_fmt_message_5(_jspx_page_context)) return; out.write(":\n </td>\n <td>\n "); List<String> groupList = item.getGroups(); if (!groupList.isEmpty()) { int count = 0; for (String group : groupList) { if (count != 0) { out.print(","); } out.print(StringUtils.escapeForXML(group)); count++; } } else { out.print("<i>None</i>"); } out.write( "\n </td>\n </tr>\n <tr>\n <td class=\"c1\">\n <a href=\"group-summary.jsp\">"); if (_jspx_meth_fmt_message_6(_jspx_page_context)) return; out.write("</a>:\n </td>\n <td>\n "); Collection<Group> sharedGroups = item.getSharedGroups(); if (!sharedGroups.isEmpty()) { int count = 0; for (Group group : sharedGroups) { if (count != 0) { out.print(","); } out.print( "<a href='group-edit.jsp?group=" + URLEncoder.encode(group.getName(), "UTF-8") + "'>"); out.print(StringUtils.escapeForXML(group.getName())); out.print("</a>"); count++; } } else { out.print("<i>None</i>"); } out.write( "\n </td>\n </tr>\n <tr>\n <td class=\"c1\">\n "); if (_jspx_meth_fmt_message_7(_jspx_page_context)) return; out.write(":\n </td>\n <td>\n "); out.print(StringUtils.escapeHTMLTags(item.getSubStatus().getName())); out.write( "\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n</fieldset>\n\n<br><br>\n\n<form style=\"display: inline\" action=\"user-roster-edit.jsp\">\n<input type=\"hidden\" name=\"jid\" value=\""); out.print(StringUtils.escapeForXML(jid)); out.write("\">\n<input type=\"hidden\" name=\"username\" value=\""); out.print(StringUtils.escapeForXML(username)); out.write("\">\n<input type=\"submit\" value=\""); if (_jspx_meth_fmt_message_8(_jspx_page_context)) return; out.write("\">\n</form>\n\n"); if (sharedGroups.isEmpty()) { out.write( "\n<form style=\"display: inline\" action=\"user-roster-delete.jsp\">\n<input type=\"hidden\" name=\"jid\" value=\""); out.print(StringUtils.escapeForXML(jid)); out.write("\">\n<input type=\"hidden\" name=\"username\" value=\""); out.print(StringUtils.escapeForXML(username)); out.write("\">\n<input type=\"submit\" value=\""); if (_jspx_meth_fmt_message_9(_jspx_page_context)) return; out.write("\">\n</form>\n"); } out.write("\n\n </body>\n</html>\n"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); } }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html"); pageContext = _jspxFactory.getPageContext(this, request, response, "error.jsp", true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\n\n\n\n\n"); org.jivesoftware.admin.AdminPageBean pageinfo = null; synchronized (request) { pageinfo = (org.jivesoftware.admin.AdminPageBean) _jspx_page_context.getAttribute("pageinfo", PageContext.REQUEST_SCOPE); if (pageinfo == null) { pageinfo = new org.jivesoftware.admin.AdminPageBean(); _jspx_page_context.setAttribute("pageinfo", pageinfo, PageContext.REQUEST_SCOPE); } } out.write('\n'); out.write('\n'); out.write('\n'); out.write('\n'); // Get parameters String log = ParamUtils.getParameter(request, "log"); String numLinesParam = ParamUtils.getParameter(request, "lines"); int numLines = ParamUtils.getIntParameter(request, "lines", 50); String mode = ParamUtils.getParameter(request, "mode"); // Only allow requests for valid log file names. if (!("debug".equals(log) || "warn".equals(log) || "info".equals(log) || "error".equals(log))) { log = null; } // Set defaults if (log == null) { log = "error"; } if (mode == null) { mode = "asc"; } if (numLinesParam == null) { numLinesParam = "50"; } // Other vars File logDir = new File(Log.getLogDirectory()); String filename = log + ".log"; File logFile = new File(logDir, filename); String lines[] = new String[0]; int start = 0; try { BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(logFile), "UTF-8")); String line; int totalNumLines = 0; while ((line = in.readLine()) != null) { totalNumLines++; } in.close(); // adjust the 'numLines' var to match totalNumLines if 'all' was passed in: if ("All".equals(numLinesParam)) { numLines = totalNumLines; } lines = new String[numLines]; in = new BufferedReader(new InputStreamReader(new FileInputStream(logFile), "UTF-8")); // skip lines start = totalNumLines - numLines; if (start < 0) { start = 0; } for (int i = 0; i < start; i++) { in.readLine(); } int i = 0; if ("asc".equals(mode)) { while ((line = in.readLine()) != null && i < numLines) { line = StringUtils.escapeHTMLTags(line); line = parseDate(line); line = hilite(line); lines[i] = line; i++; } } else { int end = lines.length - 1; while ((line = in.readLine()) != null && i < numLines) { line = StringUtils.escapeHTMLTags(line); line = parseDate(line); line = hilite(line); lines[end - i] = line; i++; } } numLines = start + i; } catch (FileNotFoundException ex) { Log.info("Could not open (log)file.", ex); } out.write("\n\n<html>\n<head>\n <title>"); out.print(log); out.write( "</title>\n <meta name=\"decorator\" content=\"none\"/>\n <style type=\"text/css\">\n .log TABLE {\n border : 1px #ccc solid;\n }\n .log TH {\n font-family : verdana, arial, sans-serif;\n font-weight : bold;\n font-size : 8pt;\n }\n .log TR TH {\n background-color : #ddd;\n border-bottom : 1px #ccc solid;\n padding-left : 2px;\n padding-right : 2px;\n text-align : left;\n }\n .log .head-num {\n border-right : 1px #ccc solid;\n }\n .log TD {\n font-family : courier new,monospace;\n font-size : 9pt;\n background-color : #ffe;\n }\n .log .num {\n width : 1%;\n background-color : #eee !important;\n border-right : 1px #ccc solid;\n padding-left : 2px;\n padding-right : 2px;\n }\n .log .line {\n padding-left : 10px;\n }\n .hilite {\n color : #900;\n }\n .hilite-marker {\n background-color : #ff0;\n color : #000;\n font-weight : bold;\n }\n </style>\n"); out.write( "</head>\n<body>\n\n<div class=\"log\">\n<table cellpadding=\"1\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n<tr>\n <th class=\"head-num\">"); if (_jspx_meth_fmt_message_0(_jspx_page_context)) return; out.write( "</th>\n <th> </th>\n</tr>\n<tr>\n <td width=\"1%\" nowrap class=\"num\">\n "); if ("asc".equals(mode)) { out.write("\n "); for (int j = start + 1; j <= numLines; j++) { out.write("\n "); out.print(j); out.write("<br>\n "); } out.write("\n "); } else { out.write("\n "); for (int j = numLines; j >= start + 1; j--) { out.write("\n "); out.print(j); out.write("<br>\n "); } out.write("\n "); } out.write("\n </td>\n <td width=\"99%\" class=\"line\">\n "); for (String line1 : lines) { if (line1 != null) { out.write("\n <nobr>"); out.print(line1); out.write("\n </nobr>\n <br>\n\n "); } } out.write("\n </td>\n</tr>\n</table>\n</div>\n\n</body>\n</html>"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); } }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html"); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\n\n\n\n\n\n\n\n\n\n\n\n\n"); // Get handle on the Monitoring plugin MonitoringPlugin plugin = (MonitoringPlugin) XMPPServer.getInstance().getPluginManager().getPlugin("monitoring"); ConversationManager conversationManager = (ConversationManager) plugin.getModule(ConversationManager.class); XMPPServer server = XMPPServer.getInstance(); UserManager userManager = UserManager.getInstance(); out.write( "\n\n<html>\n <head>\n <title>Conversations</title>\n <meta name=\"pageID\" content=\"active-conversations\"/>\n <script src=\"/js/prototype.js\" type=\"text/javascript\"></script>\n <script src=\"/js/scriptaculous.js\" type=\"text/javascript\"></script>\n <script src=\"/plugins/monitoring/dwr/engine.js\" type=\"text/javascript\" ></script>\n <script src=\"/plugins/monitoring/dwr/util.js\" type=\"text/javascript\" ></script>\n <script src=\"/plugins/monitoring/dwr/interface/conversations.js\" type=\"text/javascript\"></script>\n </head>\n <body>\n\n<style type=\"text/css\">\n\t@import \"style/style.css\";\n</style>\n<script type=\"text/javascript\">\nDWREngine.setErrorHandler(handleError);\nwindow.onerror = handleError;\nfunction handleError() {\n // swallow errors: probably caused by the server being down\n}\n\nvar peConversations = new PeriodicalExecuter(conversationUpdater, 10);\n\nfunction conversationUpdater() {\n try {\n conversations.getConversations(updateConversations, true);\n } catch(err) {\n"); out.write( " // swallow errors\n }\n}\n\nfunction updateConversations(data) {\n conversationsTable = $('conversations');\n rows = conversationsTable.getElementsByTagName(\"tr\");\n // loop over existing rows in the table\n var rowsToDelete = new Array();\n for (i = 0; i < rows.length; i++) {\n // is this a conversation row?\n if (rows[i].id == 'noconversations') {\n rowsToDelete.push(i);\n } else if (rows[i].id != '') {\n // does the conversation exist in update we received?\n convID = rows[i].id.replace('conversation-', '');\n if (data[convID] != undefined) {\n\n row = rows[i];\n cells = row.getElementsByTagName('td');\n conversation = data[convID];\n if (cells[3].innerHTML != conversation.messageCount) {\n users = conversation.participant1 + '<br />' + conversation.participant2;\n cells[0].innerHTML = users;\n cells[1].innerHTML = conversation.duration;\n"); out.write( " cells[2].innerHTML = conversation.lastActivity;\n cells[3].innerHTML = conversation.messageCount;\n new Effect.Highlight(row, {duration: 3.0});\n }\n // doesn't exist in update, delete from table\n } else {\n rowsToDelete.push(i);\n }\n }\n }\n\n for (i=0; i<rowsToDelete.length; i++) {\n conversationsTable.deleteRow(rowsToDelete[i]);\n }\n\n\n // then add any new conversations from the update\n counter = 0;\n for (var c in data) {\n counter++;\n // does this conversation already exist?\n if ($('conversation-' + c) == undefined) {\n conversation = data[c];\n users = conversation.participant1 + '<br />' + conversation.participant2;\n var newTR = document.createElement(\"tr\");\n newTR.setAttribute('id', 'conversation-' + c)\n conversationsTable.appendChild(newTR);\n var TD = document.createElement(\"TD\");\n"); out.write( " TD.innerHTML = users;\n newTR.appendChild(TD);\n\n TD = document.createElement(\"TD\");\n TD.innerHTML = conversation.duration;\n newTR.appendChild(TD);\n\n TD = document.createElement(\"TD\");\n TD.innerHTML = conversation.lastActivity;\n newTR.appendChild(TD);\n\n TD = document.createElement(\"TD\");\n TD.innerHTML = conversation.messageCount;\n newTR.appendChild(TD);\n }\n }\n\n // update activeConversations number\n $('activeConversations').innerHTML = counter;\n}\n\n</script>\n\n<!-- <a href=\"#\" onclick=\"conversationUpdater(); return false;\">click me</a> -->\n<p>\n "); if (_jspx_meth_fmt_message_0(_jspx_page_context)) return; out.write("\n <span id=\"activeConversations\">"); out.print(conversationManager.getConversationCount()); out.write("</span\n</p>\n\n"); Collection<Conversation> conversations = conversationManager.getConversations(); out.write( "\n\n\n<div class=\"jive-table\">\n<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\" id=\"conversations\">\n<thead>\n <tr>\n <th nowrap>"); if (_jspx_meth_fmt_message_1(_jspx_page_context)) return; out.write("</th>\n <th nowrap>"); if (_jspx_meth_fmt_message_2(_jspx_page_context)) return; out.write("</th>\n <th nowrap>"); if (_jspx_meth_fmt_message_3(_jspx_page_context)) return; out.write("</th>\n <th nowrap>"); if (_jspx_meth_fmt_message_4(_jspx_page_context)) return; out.write("</th>\n </tr>\n</thead>\n<tbody>\n "); if (conversations.isEmpty()) { out.write( "\n <tr id=\"noconversations\">\n <td colspan=\"4\">\n "); if (_jspx_meth_fmt_message_5(_jspx_page_context)) return; out.write("\n </td>\n </tr>\n\n "); } out.write("\n "); for (Conversation conversation : conversations) { Collection<JID> participants = conversation.getParticipants(); out.write("\n <tr id=\"conversation-"); out.print(conversation.getConversationID()); out.write("\">\n <td>\n "); if (conversation.getRoom() == null) { out.write("\n "); for (JID jid : participants) { out.write("\n "); if (server.isLocal(jid) && userManager.isRegisteredUser(jid.getNode())) { out.write("\n <a href=\"/user-properties.jsp?username="******"'); out.write('>'); out.print(jid); out.write("</a><br />\n "); } else { out.write("\n "); out.print(jid.toBareJID()); out.write("<br/>\n "); } out.write("\n "); } out.write("\n "); } else { out.write("\n "); // fmt:message org.apache.taglibs.standard.tag.rt.fmt.MessageTag _jspx_th_fmt_message_6 = (org.apache.taglibs.standard.tag.rt.fmt.MessageTag) _jspx_tagPool_fmt_message_key.get( org.apache.taglibs.standard.tag.rt.fmt.MessageTag.class); _jspx_th_fmt_message_6.setPageContext(_jspx_page_context); _jspx_th_fmt_message_6.setParent(null); _jspx_th_fmt_message_6.setKey("archive.group_conversation"); int _jspx_eval_fmt_message_6 = _jspx_th_fmt_message_6.doStartTag(); if (_jspx_eval_fmt_message_6 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { if (_jspx_eval_fmt_message_6 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) { out = _jspx_page_context.pushBody(); _jspx_th_fmt_message_6.setBodyContent((javax.servlet.jsp.tagext.BodyContent) out); _jspx_th_fmt_message_6.doInitBody(); } do { out.write("\n "); // fmt:param org.apache.taglibs.standard.tag.rt.fmt.ParamTag _jspx_th_fmt_param_0 = (org.apache.taglibs.standard.tag.rt.fmt.ParamTag) _jspx_tagPool_fmt_param_value_nobody.get( org.apache.taglibs.standard.tag.rt.fmt.ParamTag.class); _jspx_th_fmt_param_0.setPageContext(_jspx_page_context); _jspx_th_fmt_param_0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_fmt_message_6); _jspx_th_fmt_param_0.setValue( "<a href='../../muc-room-occupants.jsp?roomJID=" + URLEncoder.encode(conversation.getRoom().toBareJID(), "UTF-8") + "'>"); int _jspx_eval_fmt_param_0 = _jspx_th_fmt_param_0.doStartTag(); if (_jspx_th_fmt_param_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _jspx_tagPool_fmt_param_value_nobody.reuse(_jspx_th_fmt_param_0); return; } _jspx_tagPool_fmt_param_value_nobody.reuse(_jspx_th_fmt_param_0); out.write("\n "); // fmt:param org.apache.taglibs.standard.tag.rt.fmt.ParamTag _jspx_th_fmt_param_1 = (org.apache.taglibs.standard.tag.rt.fmt.ParamTag) _jspx_tagPool_fmt_param_value_nobody.get( org.apache.taglibs.standard.tag.rt.fmt.ParamTag.class); _jspx_th_fmt_param_1.setPageContext(_jspx_page_context); _jspx_th_fmt_param_1.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_fmt_message_6); _jspx_th_fmt_param_1.setValue("</a>"); int _jspx_eval_fmt_param_1 = _jspx_th_fmt_param_1.doStartTag(); if (_jspx_th_fmt_param_1.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _jspx_tagPool_fmt_param_value_nobody.reuse(_jspx_th_fmt_param_1); return; } _jspx_tagPool_fmt_param_value_nobody.reuse(_jspx_th_fmt_param_1); out.write("\n "); int evalDoAfterBody = _jspx_th_fmt_message_6.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); if (_jspx_eval_fmt_message_6 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) out = _jspx_page_context.popBody(); } if (_jspx_th_fmt_message_6.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _jspx_tagPool_fmt_message_key.reuse(_jspx_th_fmt_message_6); return; } _jspx_tagPool_fmt_message_key.reuse(_jspx_th_fmt_message_6); out.write("\n "); } out.write("\n </td>\n "); long duration = conversation.getLastActivity().getTime() - conversation.getStartDate().getTime(); out.write("\n <td>"); out.print(StringUtils.getTimeFromLong(duration)); out.write("</td>\n <td>"); out.print(JiveGlobals.formatTime(conversation.getLastActivity())); out.write("</td>\n <td>"); out.print(conversation.getMessageCount()); out.write("</td>\n </tr>\n "); } out.write("\n</tbody>\n</table>\n</div>\n\n</body>\n</html>"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); } }
public String getDuration() { return StringUtils.getTimeFromLong(duration); }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html"); pageContext = _jspxFactory.getPageContext(this, request, response, "../error.jsp", true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\n\n\n\n\n\n\n\n\n"); org.jivesoftware.admin.AdminPageBean info = null; synchronized (request) { info = (org.jivesoftware.admin.AdminPageBean) _jspx_page_context.getAttribute("info", PageContext.REQUEST_SCOPE); if (info == null) { info = new org.jivesoftware.admin.AdminPageBean(); _jspx_page_context.setAttribute("info", info, PageContext.REQUEST_SCOPE); } } out.write('\n'); out.write('\n'); org.jivesoftware.util.WebManager webManager = null; synchronized (_jspx_page_context) { webManager = (org.jivesoftware.util.WebManager) _jspx_page_context.getAttribute("webManager", PageContext.PAGE_SCOPE); if (webManager == null) { webManager = new org.jivesoftware.util.WebManager(); _jspx_page_context.setAttribute("webManager", webManager, PageContext.PAGE_SCOPE); } } out.write('\n'); webManager.init(request, response, session, application, out); out.write('\n'); out.write('\n'); // decorator:usePage com.opensymphony.module.sitemesh.taglib.decorator.UsePageTag _jspx_th_decorator_usePage_0 = (com.opensymphony.module.sitemesh.taglib.decorator.UsePageTag) _jspx_tagPool_decorator_usePage_id_nobody.get( com.opensymphony.module.sitemesh.taglib.decorator.UsePageTag.class); _jspx_th_decorator_usePage_0.setPageContext(_jspx_page_context); _jspx_th_decorator_usePage_0.setParent(null); _jspx_th_decorator_usePage_0.setId("decoratedPage"); int _jspx_eval_decorator_usePage_0 = _jspx_th_decorator_usePage_0.doStartTag(); if (_jspx_th_decorator_usePage_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _jspx_tagPool_decorator_usePage_id_nobody.reuse(_jspx_th_decorator_usePage_0); return; } _jspx_tagPool_decorator_usePage_id_nobody.reuse(_jspx_th_decorator_usePage_0); com.opensymphony.module.sitemesh.Page decoratedPage = null; decoratedPage = (com.opensymphony.module.sitemesh.Page) _jspx_page_context.findAttribute("decoratedPage"); out.write('\n'); out.write('\n'); String path = request.getContextPath(); // Decorated pages will typically must set a pageID and optionally set a subPageID // and extraParams. Store these values as request attributes so that the tab and sidebar // handling tags can get at the data. request.setAttribute("pageID", decoratedPage.getProperty("meta.pageID")); request.setAttribute("subPageID", decoratedPage.getProperty("meta.subPageID")); request.setAttribute("extraParams", decoratedPage.getProperty("meta.extraParams")); // Message HTML can be passed in: String message = decoratedPage.getProperty("page.message"); out.write("\n\n<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n\n"); if (_jspx_meth_fmt_setBundle_0(_jspx_page_context)) return; out.write("\n<html>\n<head>\n <title>"); out.print(AdminConsole.getAppName()); out.write(' '); if (_jspx_meth_fmt_message_0(_jspx_page_context)) return; out.write(':'); out.write(' '); if (_jspx_meth_decorator_title_0(_jspx_page_context)) return; out.write( "</title>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n <link rel=\"stylesheet\" type=\"text/css\" href=\""); out.print(path); out.write( "/style/global.css\">\n <script language=\"JavaScript\" type=\"text/javascript\" src=\""); out.print(path); out.write( "/js/prototype.js\"></script>\n <script language=\"JavaScript\" type=\"text/javascript\" src=\""); out.print(path); out.write( "/js/scriptaculous.js\"></script>\n <script language=\"JavaScript\" type=\"text/javascript\" src=\""); out.print(path); out.write( "/js/cookies.js\"></script>\n <script language=\"JavaScript\" type=\"text/javascript\">\n\n </script>\n <script type=\"text/javascript\" src=\""); out.print(path); out.write( "/js/behaviour.js\"></script>\n <script type=\"text/javascript\">\n // Add a nice little rollover effect to any row in a jive-table object. This will help\n // visually link left and right columns.\n /*\n var myrules = {\n '.jive-table TBODY TR' : function(el) {\n el.onmouseover = function() {\n this.style.backgroundColor = '#ffffee';\n }\n el.onmouseout = function() {\n this.style.backgroundColor = '#ffffff';\n }\n }\n };\n Behaviour.register(myrules);\n */\n </script>\n "); if (_jspx_meth_decorator_head_0(_jspx_page_context)) return; out.write( "\n</head>\n\n<body id=\"jive-body\">\n\n<!-- BEGIN main -->\n<div id=\"main\">\n\n <div id=\"jive-header\">\n <div id=\"jive-logo\">\n <a href=\"/index.jsp\"><img src=\"/images/login_logo.gif\" alt=\"Openfire\" width=\"179\" height=\"53\" /></a>\n </div>\n <div id=\"jive-userstatus\">\n "); out.print(AdminConsole.getAppName()); out.write(' '); out.print(AdminConsole.getVersionString()); out.write("<br/>\n "); // fmt:message org.apache.taglibs.standard.tag.rt.fmt.MessageTag _jspx_th_fmt_message_1 = (org.apache.taglibs.standard.tag.rt.fmt.MessageTag) _jspx_tagPool_fmt_message_key.get( org.apache.taglibs.standard.tag.rt.fmt.MessageTag.class); _jspx_th_fmt_message_1.setPageContext(_jspx_page_context); _jspx_th_fmt_message_1.setParent(null); _jspx_th_fmt_message_1.setKey("admin.logged_in_as"); int _jspx_eval_fmt_message_1 = _jspx_th_fmt_message_1.doStartTag(); if (_jspx_eval_fmt_message_1 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) { if (_jspx_eval_fmt_message_1 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) { out = _jspx_page_context.pushBody(); _jspx_th_fmt_message_1.setBodyContent((javax.servlet.jsp.tagext.BodyContent) out); _jspx_th_fmt_message_1.doInitBody(); } do { // fmt:param org.apache.taglibs.standard.tag.rt.fmt.ParamTag _jspx_th_fmt_param_0 = (org.apache.taglibs.standard.tag.rt.fmt.ParamTag) _jspx_tagPool_fmt_param_value_nobody.get( org.apache.taglibs.standard.tag.rt.fmt.ParamTag.class); _jspx_th_fmt_param_0.setPageContext(_jspx_page_context); _jspx_th_fmt_param_0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_fmt_message_1); _jspx_th_fmt_param_0.setValue( "<strong>" + StringUtils.escapeHTMLTags(JID.unescapeNode(webManager.getUser().getUsername())) + "</strong>"); int _jspx_eval_fmt_param_0 = _jspx_th_fmt_param_0.doStartTag(); if (_jspx_th_fmt_param_0.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _jspx_tagPool_fmt_param_value_nobody.reuse(_jspx_th_fmt_param_0); return; } _jspx_tagPool_fmt_param_value_nobody.reuse(_jspx_th_fmt_param_0); int evalDoAfterBody = _jspx_th_fmt_message_1.doAfterBody(); if (evalDoAfterBody != javax.servlet.jsp.tagext.BodyTag.EVAL_BODY_AGAIN) break; } while (true); if (_jspx_eval_fmt_message_1 != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE) out = _jspx_page_context.popBody(); } if (_jspx_th_fmt_message_1.doEndTag() == javax.servlet.jsp.tagext.Tag.SKIP_PAGE) { _jspx_tagPool_fmt_message_key.reuse(_jspx_th_fmt_message_1); return; } _jspx_tagPool_fmt_message_key.reuse(_jspx_th_fmt_message_1); out.write(" - <a href=\""); out.print(path); out.write("/index.jsp?logout=true\">"); out.print(LocaleUtils.getLocalizedString("global.logout")); out.write( "</a>\n </div>\n <div id=\"jive-nav\">\n <div id=\"jive-nav-left\"></div>\n "); if (_jspx_meth_admin_tabs_0(_jspx_page_context)) return; out.write( "\n <div id=\"jive-nav-right\"></div>\n </div>\n <div id=\"jive-subnav\">\n "); if (_jspx_meth_admin_subnavbar_0(_jspx_page_context)) return; out.write( "\n </div>\n </div>\n\n <div id=\"jive-main\">\n <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n <tbody>\n <tr valign=\"top\">\n <td width=\"1%\">\n <div id=\"jive-sidebar-container\">\n <div id=\"jive-sidebar-box\">\n <div id=\"jive-sidebar\">\n "); if (_jspx_meth_admin_sidebar_0(_jspx_page_context)) return; out.write("\n <br>\n <img src=\""); out.print(path); out.write( "/images/blank.gif\" width=\"150\" height=\"1\" border=\"0\" alt=\"\">\n </div>\n </div>\n </div>\n </td>\n <td width=\"99%\" id=\"jive-content\">\n\n\n "); if (message != null) { out.write("\n\n "); out.print(message); out.write("\n\n "); } out.write("\n\n <h1>\n "); if (_jspx_meth_decorator_title_1(_jspx_page_context)) return; out.write( "\n </h1>\n\n <div id=\"jive-main-content\">\n "); if (_jspx_meth_decorator_body_0(_jspx_page_context)) return; out.write( "\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n\n</div>\n<!-- END main -->\n\n<!-- BEGIN footer -->\n\t<div id=\"jive-footer\">\n <div class=\"jive-footer-nav\">\n "); if (_jspx_meth_admin_tabs_1(_jspx_page_context)) return; out.write( "\n </div>\n <div class=\"jive-footer-copyright\">\n Built by <a href=\"http://www.jivesoftware.com\">Jive Software</a> and the <a href=\"http://www.igniterealtime.org\">IgniteRealtime.org</a> community\n </div>\n </div>\n<!-- END footer -->\n\n</body>\n</html>\n"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); } }
public void start() throws IllegalStateException { super.start(); if (isEnabled()) { // Before starting up service make sure there is a default secret if (ExternalComponentManager.getDefaultSecret() == null || "".equals(ExternalComponentManager.getDefaultSecret())) { try { ExternalComponentManager.setDefaultSecret(StringUtils.randomString(10)); } catch (ModificationNotAllowedException e) { Log.warn("Failed to set a default secret to external component service", e); } } // Make sure that external component service is enabled if (!ExternalComponentManager.isServiceEnabled()) { try { ExternalComponentManager.setServiceEnabled(true); } catch (ModificationNotAllowedException e) { Log.warn("Failed to start external component service", e); } } // Listen for changes to external component settings ExternalComponentManager.addListener(this); // Listen for registration of new components InternalComponentManager.getInstance().addListener(this); // Listen for changes in certificates CertificateManager.addListener(this); // Listen for property changes PropertyEventDispatcher.addListener(this); // Set up custom clearspace MUC service // Create service if it doesn't exist, load if it does. MultiUserChatServiceImpl muc = (MultiUserChatServiceImpl) XMPPServer.getInstance() .getMultiUserChatManager() .getMultiUserChatService(MUC_SUBDOMAIN); if (muc == null) { try { muc = XMPPServer.getInstance() .getMultiUserChatManager() .createMultiUserChatService(MUC_SUBDOMAIN, MUC_DESCRIPTION, true); } catch (AlreadyExistsException e) { Log.error( "ClearspaceManager: Found no " + MUC_SUBDOMAIN + " service, but got already exists when creation attempted? Service probably not started!"); } } if (muc != null) { // Set up special delegate for Clearspace MUC service muc.setMUCDelegate(new ClearspaceMUCEventDelegate()); // Set up additional features for Clearspace MUC service muc.addExtraFeature("clearspace:service"); // Set up additional identity of conference service to Clearspace MUC service muc.addExtraIdentity("conference", "Clearspace Chat Service", "text"); } // Starts the clearspace configuration task startClearspaceConfig(); // Starts the Clearspace MUC transcript manager mucTranscriptManager.start(); } }
/** * The admin console plugin. It starts a Jetty instance on the configured port and loads the admin * console web application. * * @author Matt Tucker */ public class AdminConsolePlugin implements Plugin { private static final Logger Log = LoggerFactory.getLogger(AdminConsolePlugin.class); /** * Random secret used by JVM to allow SSO. Only other cluster nodes can use this secret as a way * to integrate the admin consoles of each cluster node. */ public static final String secret = StringUtils.randomString(64); private int adminPort; private int adminSecurePort; private Server adminServer; private ContextHandlerCollection contexts; private CertificateEventListener certificateListener; private boolean restartNeeded = false; private boolean sslEnabled = false; private File pluginDir; /** Create a Jetty module. */ public AdminConsolePlugin() { contexts = new ContextHandlerCollection(); // Configure Jetty logging to a more reasonable default. System.setProperty( "org.eclipse.jetty.util.log.class", "org.jivesoftware.util.log.util.JettyLog"); // JSP 2.0 uses commons-logging, so also override that implementation. System.setProperty( "org.apache.commons.logging.LogFactory", "org.jivesoftware.util.log.util.CommonsLogFactory"); } /** Starts the Jetty instance. */ public void startup() { restartNeeded = false; // Add listener for certificate events certificateListener = new CertificateListener(); CertificateManager.addListener(certificateListener); adminPort = JiveGlobals.getXMLProperty("adminConsole.port", 9090); adminSecurePort = JiveGlobals.getXMLProperty("adminConsole.securePort", 9091); adminServer = new Server(); final QueuedThreadPool tp = new QueuedThreadPool(254); tp.setName("Jetty-QTP-AdminConsole"); adminServer.setThreadPool(tp); // Do not send Jetty info in HTTP headers adminServer.setSendServerVersion(false); // Create connector for http traffic if it's enabled. if (adminPort > 0) { Connector httpConnector = new SelectChannelConnector(); // Listen on a specific network interface if it has been set. String bindInterface = getBindInterface(); httpConnector.setHost(bindInterface); httpConnector.setPort(adminPort); adminServer.addConnector(httpConnector); } // Create a connector for https traffic if it's enabled. sslEnabled = false; try { if (adminSecurePort > 0 && CertificateManager.isRSACertificate(SSLConfig.getKeyStore(), "*")) { if (!CertificateManager.isRSACertificate( SSLConfig.getKeyStore(), XMPPServer.getInstance().getServerInfo().getXMPPDomain())) { Log.warn( "Admin console: Using RSA certificates but they are not valid for the hosted domain"); } JiveSslConnector httpsConnector = new JiveSslConnector(); String bindInterface = getBindInterface(); httpsConnector.setHost(bindInterface); httpsConnector.setPort(adminSecurePort); httpsConnector.setTrustPassword(SSLConfig.gets2sTrustPassword()); httpsConnector.setTruststoreType(SSLConfig.getStoreType()); httpsConnector.setTruststore(SSLConfig.gets2sTruststoreLocation()); httpsConnector.setNeedClientAuth(false); httpsConnector.setWantClientAuth(false); httpsConnector.setKeyPassword(SSLConfig.getKeyPassword()); httpsConnector.setKeystoreType(SSLConfig.getStoreType()); httpsConnector.setKeystore(SSLConfig.getKeystoreLocation()); adminServer.addConnector(httpsConnector); sslEnabled = true; } } catch (Exception e) { Log.error(e.getMessage(), e); } // Make sure that at least one connector was registered. if (adminServer.getConnectors() == null || adminServer.getConnectors().length == 0) { adminServer = null; // Log warning. log(LocaleUtils.getLocalizedString("admin.console.warning")); return; } HandlerCollection collection = new HandlerCollection(); adminServer.setHandler(collection); collection.setHandlers(new Handler[] {contexts, new DefaultHandler()}); try { adminServer.start(); } catch (Exception e) { Log.error("Could not start admin conosle server", e); } // Log the ports that the admin server is listening on. logAdminConsolePorts(); } /** Shuts down the Jetty server. */ public void shutdown() { // Remove listener for certificate events if (certificateListener != null) { CertificateManager.removeListener(certificateListener); } //noinspection ConstantConditions try { if (adminServer != null && adminServer.isRunning()) { adminServer.stop(); } } catch (Exception e) { Log.error("Error stopping admin console server", e); } adminServer = null; } public void initializePlugin(PluginManager manager, File pluginDir) { this.pluginDir = pluginDir; createWebAppContext(); startup(); } public void destroyPlugin() { shutdown(); } /** * Returns true if the Jetty server needs to be restarted. This is usually required when * certificates are added, deleted or modified or when server ports were modified. * * @return true if the Jetty server needs to be restarted. */ public boolean isRestartNeeded() { return restartNeeded; } /** * Returns <tt>null</tt> if the admin console will be available in all network interfaces of this * machine or a String representing the only interface where the admin console will be available. * * @return String representing the only interface where the admin console will be available or * null if it will be available in all interfaces. */ public String getBindInterface() { String adminInterfaceName = JiveGlobals.getXMLProperty("adminConsole.interface"); String globalInterfaceName = JiveGlobals.getXMLProperty("network.interface"); String bindInterface = null; if (adminInterfaceName != null && adminInterfaceName.trim().length() > 0) { bindInterface = adminInterfaceName; } else if (globalInterfaceName != null && globalInterfaceName.trim().length() > 0) { bindInterface = globalInterfaceName; } return bindInterface; } /** * Returns the non-SSL port on which the admin console is currently operating. * * @return the non-SSL port on which the admin console is currently operating. */ public int getAdminUnsecurePort() { return adminPort; } /** * Returns the SSL port on which the admin console is current operating. * * @return the SSL port on which the admin console is current operating. */ public int getAdminSecurePort() { if (!sslEnabled) { return 0; } return adminSecurePort; } /** * Returns the collection of Jetty contexts used in the admin console. A root context "/" is where * the admin console lives. Additional contexts can be added dynamically for other web * applications that should be run as part of the admin console server process. The following * pseudo code demonstrates how to do this: * * <pre> * ContextHandlerCollection contexts = ((AdminConsolePlugin)pluginManager.getPlugin("admin")).getContexts(); * context = new WebAppContext(SOME_DIRECTORY, "/CONTEXT_NAME"); * contexts.addHandler(context); * context.setWelcomeFiles(new String[]{"index.jsp"}); * context.start(); * </pre> * * @return the Jetty handlers. */ public ContextHandlerCollection getContexts() { return contexts; } public void restart() { try { adminServer.stop(); adminServer.start(); } catch (Exception e) { Log.error(e.getMessage(), e); } } private void createWebAppContext() { ServletContextHandler context; // Add web-app. Check to see if we're in development mode. If so, we don't // add the normal web-app location, but the web-app in the project directory. if (Boolean.getBoolean("developmentMode")) { System.out.println(LocaleUtils.getLocalizedString("admin.console.devmode")); context = new WebAppContext( contexts, pluginDir.getParentFile().getParentFile().getParentFile().getParent() + File.separator + "src" + File.separator + "web", "/"); } else { context = new WebAppContext(contexts, pluginDir.getAbsoluteFile() + File.separator + "webapp", "/"); } context.setWelcomeFiles(new String[] {"index.jsp"}); } private void log(String string) { Log.info(string); System.out.println(string); } private void logAdminConsolePorts() { // Log what ports the admin console is running on. String listening = LocaleUtils.getLocalizedString("admin.console.listening"); String hostname = getBindInterface() == null ? XMPPServer.getInstance().getServerInfo().getXMPPDomain() : getBindInterface(); boolean isPlainStarted = false; boolean isSecureStarted = false; for (Connector connector : adminServer.getConnectors()) { if (connector.getPort() == adminPort) { isPlainStarted = true; } else if (connector.getPort() == adminSecurePort) { isSecureStarted = true; } } if (isPlainStarted && isSecureStarted) { log( listening + ":" + System.getProperty("line.separator") + " http://" + hostname + ":" + adminPort + System.getProperty("line.separator") + " https://" + hostname + ":" + adminSecurePort); } else if (isSecureStarted) { log(listening + " https://" + hostname + ":" + adminSecurePort); } else if (isPlainStarted) { log(listening + " http://" + hostname + ":" + adminPort); } } /** * Listens for security certificates being created and destroyed so we can track when the admin * console needs to be restarted. */ private class CertificateListener implements CertificateEventListener { public void certificateCreated(KeyStore keyStore, String alias, X509Certificate cert) { // If new certificate is RSA then (re)start the HTTPS service if ("RSA".equals(cert.getPublicKey().getAlgorithm())) { restartNeeded = true; } } public void certificateDeleted(KeyStore keyStore, String alias) { restartNeeded = true; } public void certificateSigned( KeyStore keyStore, String alias, List<X509Certificate> certificates) { // If new certificate is RSA then (re)start the HTTPS service if ("RSA".equals(certificates.get(0).getPublicKey().getAlgorithm())) { restartNeeded = true; } } } private class JiveSslConnector extends SslSelectChannelConnector { @Override protected SSLContext createSSLContext() throws Exception { return SSLConfig.getSSLContext(); } } }
public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { JspFactory _jspxFactory = null; PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { _jspxFactory = JspFactory.getDefaultFactory(); response.setContentType("text/html"); pageContext = _jspxFactory.getPageContext(this, request, response, "error.jsp", true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write("\n\n\n\n\n\n\n\n\n"); out.write('\n'); org.jivesoftware.util.WebManager webManager = null; synchronized (_jspx_page_context) { webManager = (org.jivesoftware.util.WebManager) _jspx_page_context.getAttribute("webManager", PageContext.PAGE_SCOPE); if (webManager == null) { webManager = new org.jivesoftware.util.WebManager(); _jspx_page_context.setAttribute("webManager", webManager, PageContext.PAGE_SCOPE); } } out.write('\n'); webManager.init(request, response, session, application, out); out.write('\n'); out.write('\n'); // Get paramters boolean doTest = request.getParameter("test") != null; boolean cancel = request.getParameter("cancel") != null; boolean sent = ParamUtils.getBooleanParameter(request, "sent"); boolean success = ParamUtils.getBooleanParameter(request, "success"); String from = ParamUtils.getParameter(request, "from"); String to = ParamUtils.getParameter(request, "to"); String subject = ParamUtils.getParameter(request, "subject"); String body = ParamUtils.getParameter(request, "body"); // Cancel if requested if (cancel) { response.sendRedirect("system-email.jsp"); return; } // Variable to hold messaging exception, if one occurs Exception mex = null; // Validate input Map<String, String> errors = new HashMap<String, String>(); if (doTest) { if (from == null) { errors.put("from", ""); } if (to == null) { errors.put("to", ""); } if (subject == null) { errors.put("subject", ""); } if (body == null) { errors.put("body", ""); } EmailService service = EmailService.getInstance(); // Validate host - at a minimum, it needs to be set: String host = service.getHost(); if (host == null) { errors.put("host", ""); } // if no errors, continue if (errors.size() == 0) { // Create a message MimeMessage message = service.createMimeMessage(); // Set the date of the message to be the current date SimpleDateFormat format = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", java.util.Locale.US); format.setTimeZone(JiveGlobals.getTimeZone()); message.setHeader("Date", format.format(new Date())); // Set to and from. message.setRecipient(Message.RecipientType.TO, new InternetAddress(to, null)); message.setFrom(new InternetAddress(from, null)); message.setSubject(subject); message.setText(body); // Send the message, wrap in a try/catch: try { service.sendMessagesImmediately(Collections.singletonList(message)); // success, so indicate this: response.sendRedirect("system-emailtest.jsp?sent=true&success=true"); return; } catch (MessagingException me) { me.printStackTrace(); mex = me; } } } // Set var defaults Collection<JID> jids = webManager.getXMPPServer().getAdmins(); User user = null; if (!jids.isEmpty()) { for (JID jid : jids) { if (webManager.getXMPPServer().isLocal(jid)) { user = webManager.getUserManager().getUser(jid.getNode()); if (user.getEmail() != null) { break; } } } } if (from == null) { from = user.getEmail(); } if (to == null) { to = user.getEmail(); } if (subject == null) { subject = "Test email sent via Openfire"; } if (body == null) { body = "This is a test message."; } out.write("\n\n<html>\n <head>\n <title>"); if (_jspx_meth_fmt_message_0(_jspx_page_context)) return; out.write( "</title>\n <meta name=\"pageID\" content=\"system-email\"/>\n </head>\n <body>\n\n<script language=\"JavaScript\" type=\"text/javascript\">\nvar clicked = false;\nfunction checkClick(el) {\n if (!clicked) {\n clicked = true;\n return true;\n }\n return false;\n}\n</script>\n\n<p>\n"); if (_jspx_meth_fmt_message_1(_jspx_page_context)) return; out.write("\n</p>\n\n"); if (JiveGlobals.getProperty("mail.smtp.host") == null) { out.write( "\n\n <div class=\"jive-error\">\n <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n <tbody>\n <tr>\n \t<td class=\"jive-icon\"><img src=\"images/error-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\n\t <td class=\"jive-icon-label\">\n\t\t "); if (_jspx_meth_fmt_message_2(_jspx_page_context)) return; out.write("\n\t </td>\n </tr>\n </tbody>\n </table>\n </div>\n\n"); } out.write('\n'); out.write('\n'); if (doTest || sent) { out.write("\n\n "); if (success) { out.write( "\n\n <div class=\"jive-success\">\n <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n <tbody>\n <tr>\n \t<td class=\"jive-icon\"><img src=\"images/success-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\n \t<td class=\"jive-icon-label\">"); if (_jspx_meth_fmt_message_3(_jspx_page_context)) return; out.write( "</td>\n </tr>\n </tbody>\n </table>\n </div>\n\n "); } else { out.write( "\n\n <div class=\"jive-error\">\n <table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">\n <tbody>\n <tr><td class=\"jive-icon\"><img src=\"images/error-16x16.gif\" width=\"16\" height=\"16\" border=\"0\" alt=\"\"></td>\n <td class=\"jive-icon-label\">\n "); if (_jspx_meth_fmt_message_4(_jspx_page_context)) return; out.write("\n "); if (mex != null) { out.write("\n "); if (mex instanceof AuthenticationFailedException) { out.write("\n \t"); if (_jspx_meth_fmt_message_5(_jspx_page_context)) return; out.write(" \n "); } else { out.write("\n (Message: "); out.print(mex.getMessage()); out.write(")\n "); } out.write("\n "); } out.write( "\n </td></tr>\n </tbody>\n </table>\n </div>\n\n "); } out.write("\n\n <br>\n\n"); } out.write( "\n\n<form action=\"system-emailtest.jsp\" method=\"post\" name=\"f\" onsubmit=\"return checkClick(this);\">\n\n<table cellpadding=\"3\" cellspacing=\"0\" border=\"0\">\n<tbody>\n <tr>\n <td>\n "); if (_jspx_meth_fmt_message_6(_jspx_page_context)) return; out.write(":\n </td>\n <td>\n "); String host = JiveGlobals.getProperty("mail.smtp.host"); if (host == null) { out.write("\n <i>"); if (_jspx_meth_fmt_message_7(_jspx_page_context)) return; out.write("</i>\n "); } else { out.write("\n "); out.print(host); out.write(':'); out.print(JiveGlobals.getIntProperty("mail.smtp.port", 25)); out.write("\n\n "); if (JiveGlobals.getBooleanProperty("mail.smtp.ssl", false)) { out.write("\n\n ("); if (_jspx_meth_fmt_message_8(_jspx_page_context)) return; out.write(")\n\n "); } out.write("\n "); } out.write("\n </td>\n </tr>\n <tr>\n <td>\n "); if (_jspx_meth_fmt_message_9(_jspx_page_context)) return; out.write( ":\n </td>\n <td>\n <input type=\"hidden\" name=\"from\" value=\""); out.print(from); out.write("\">\n "); out.print(StringUtils.escapeHTMLTags(from)); out.write( "\n <span class=\"jive-description\">\n (<a href=\"user-edit-form.jsp?username="******"\">Update Address</a>)\n </span>\n </td>\n </tr>\n <tr>\n <td>\n "); if (_jspx_meth_fmt_message_10(_jspx_page_context)) return; out.write( ":\n </td>\n <td>\n <input type=\"text\" name=\"to\" value=\""); out.print(((to != null) ? to : "")); out.write( "\"\n size=\"40\" maxlength=\"100\">\n </td>\n </tr>\n <tr>\n <td>\n "); if (_jspx_meth_fmt_message_11(_jspx_page_context)) return; out.write( ":\n </td>\n <td>\n <input type=\"text\" name=\"subject\" value=\""); out.print(((subject != null) ? subject : "")); out.write( "\"\n size=\"40\" maxlength=\"100\">\n </td>\n </tr>\n <tr valign=\"top\">\n <td>\n "); if (_jspx_meth_fmt_message_12(_jspx_page_context)) return; out.write( ":\n </td>\n <td>\n <textarea name=\"body\" cols=\"45\" rows=\"5\" wrap=\"virtual\">"); out.print(body); out.write( "</textarea>\n </td>\n </tr>\n <tr>\n <td colspan=\"2\">\n <br>\n <input type=\"submit\" name=\"test\" value=\""); if (_jspx_meth_fmt_message_13(_jspx_page_context)) return; out.write("\">\n <input type=\"submit\" name=\"cancel\" value=\""); if (_jspx_meth_fmt_message_14(_jspx_page_context)) return; out.write( "\">\n </td>\n </tr>\n</tbody>\n</table>\n\n</form>\n\n </body>\n</html>"); } catch (Throwable t) { if (!(t instanceof SkipPageException)) { out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); } }
public User createUser(String username, String password, String name, String email) throws UserAlreadyExistsException { if (isReadOnly()) { // Reject the operation since the provider is read-only throw new UnsupportedOperationException(); } try { loadUser(username); // The user already exists since no exception, so: throw new UserAlreadyExistsException("Username " + username + " already exists"); } catch (UserNotFoundException unfe) { // The user doesn't already exist so we can create a new user // Determine if the password should be stored as plain text or encrypted. boolean usePlainPassword = JiveGlobals.getBooleanProperty("user.usePlainPassword"); String encryptedPassword = null; if (!usePlainPassword) { try { encryptedPassword = AuthFactory.encryptPassword(password); // Set password to null so that it's inserted that way. password = null; } catch (UnsupportedOperationException uoe) { // Encrypting the password may have failed if in setup mode. Therefore, // use the plain password. } } Date now = new Date(); Connection con = null; PreparedStatement pstmt = null; try { con = DbConnectionManager.getConnection(); pstmt = con.prepareStatement(INSERT_USER); pstmt.setString(1, username); if (password == null) { pstmt.setNull(2, Types.VARCHAR); } else { pstmt.setString(2, password); } if (encryptedPassword == null) { pstmt.setNull(3, Types.VARCHAR); } else { pstmt.setString(3, encryptedPassword); } if (name == null) { pstmt.setNull(4, Types.VARCHAR); } else { pstmt.setString(4, name); } if (email == null) { pstmt.setNull(5, Types.VARCHAR); } else { pstmt.setString(5, email); } pstmt.setString(6, StringUtils.dateToMillis(now)); pstmt.setString(7, StringUtils.dateToMillis(now)); pstmt.execute(); } catch (Exception e) { Log.error(LocaleUtils.getLocalizedString("admin.error"), e); } finally { DbConnectionManager.closeConnection(pstmt, con); } return new User(username, name, email, now, now); } }
/** * Handles a request for a JSP page in development mode. If development mode is not enabled, this * method returns false so that normal JSP handling can be performed. If development mode is * enabled, this method tries to locate the JSP, compile it using JSPC, and then return the * output. * * @param pathInfo the extra path info. * @param request the request object. * @param response the response object. * @return true if this page request was handled; false if the request was not handled. */ private boolean handleDevJSP( String pathInfo, HttpServletRequest request, HttpServletResponse response) { String jspURL = pathInfo.substring(1); // Handle pre-existing pages and fail over to pre-compiled pages. int fileSeperator = jspURL.indexOf("/"); if (fileSeperator != -1) { String pluginName = jspURL.substring(0, fileSeperator); Plugin plugin = pluginManager.getPlugin(pluginName); PluginDevEnvironment environment = pluginManager.getDevEnvironment(plugin); // If development mode not turned on for plugin, return false. if (environment == null) { return false; } File webDir = environment.getWebRoot(); if (webDir == null || !webDir.exists()) { return false; } File pluginDirectory = pluginManager.getPluginDirectory(plugin); File compilationDir = new File(pluginDirectory, "classes"); compilationDir.mkdirs(); String jsp = jspURL.substring(fileSeperator + 1); int indexOfLastSlash = jsp.lastIndexOf("/"); String relativeDir = ""; if (indexOfLastSlash != -1) { relativeDir = jsp.substring(0, indexOfLastSlash); relativeDir = relativeDir.replaceAll("//", ".") + '.'; } File jspFile = new File(webDir, jsp); String filename = jspFile.getName(); int indexOfPeriod = filename.indexOf("."); if (indexOfPeriod != -1) { filename = "dev" + StringUtils.randomString(4); } JspC jspc = new JspC(); if (!jspFile.exists()) { return false; } try { jspc.setJspFiles(jspFile.getCanonicalPath()); } catch (IOException e) { Log.error(e.getMessage(), e); } jspc.setOutputDir(compilationDir.getAbsolutePath()); jspc.setClassName(filename); jspc.setCompile(true); jspc.setClassPath(getClasspathForPlugin(plugin)); try { jspc.execute(); try { Object servletInstance = pluginManager .loadClass(plugin, "org.apache.jsp." + relativeDir + filename) .newInstance(); HttpServlet servlet = (HttpServlet) servletInstance; servlet.init(servletConfig); servlet.service(request, response); return true; } catch (Exception e) { Log.error(e.getMessage(), e); } } catch (JasperException e) { Log.error(e.getMessage(), e); } } return false; }
protected void handleSnacResponse(SnacResponseEvent e) { super.handleSnacResponse(e); Log.debug("OSCAR bos snac response received: " + e); SnacCommand cmd = e.getSnacCommand(); if (cmd instanceof LocRightsCmd) { request(new SetInfoCmd(new InfoData("oscargateway", null, MY_CAPS, null))); request(new MyInfoRequest()); } else if (cmd instanceof ParamInfoCmd) { ParamInfoCmd pic = (ParamInfoCmd) cmd; ParamInfo info = pic.getParamInfo(); request( new SetParamInfoCmd( new ParamInfo( 0, info.getFlags() | ParamInfo.FLAG_TYPING_NOTIFICATION, 8000, info.getMaxSenderWarning(), info.getMaxReceiverWarning(), 0))); } else if (cmd instanceof ServiceRedirect) { ServiceRedirect sr = (ServiceRedirect) cmd; oscarSession.connectToService(sr.getSnacFamily(), sr.getRedirectHost(), sr.getCookie()); } else if (cmd instanceof SsiDataCmd) { SsiDataCmd sdc = (SsiDataCmd) cmd; List<SsiItem> items = sdc.getItems(); for (SsiItem item : items) { SsiItemObj obj = itemFactory.getItemObj(item); if (obj instanceof BuddyItem) { Log.debug("AIM got buddy item " + obj); oscarSession.gotBuddy((BuddyItem) obj); } else if (obj instanceof GroupItem) { Log.debug("AIM got group item " + obj); oscarSession.gotGroup((GroupItem) obj); } } if (sdc.getLastModDate() != 0) { request(new ActivateSsiCmd()); clientReady(); Presence p = new Presence(); p.setTo(oscarSession.getJID()); p.setFrom(oscarSession.getTransport().getJID()); oscarSession.getTransport().sendPacket(p); oscarSession.setLoginStatus(TransportLoginStatus.LOGGED_IN); oscarSession.gotCompleteSSI(); } } else if (cmd instanceof OfflineMsgIcqCmd) { OfflineMsgIcqCmd omic = (OfflineMsgIcqCmd) cmd; String sn = String.valueOf(omic.getFromUIN()); // String msg = "Offline message sent at "+new // Date(omic.getDate().getTime()).toString()+"\n"+OscarTools.stripHtml(omic.getContents()).trim(); String msg = "Offline message received:\n" + StringUtils.unescapeFromXML(OscarTools.stripHtml(omic.getContents()).trim()); EncodedStringInfo encmsg = MinimalEncoder.encodeMinimally(msg); InstantMessage imsg = new InstantMessage( encmsg.getImEncoding().getCharsetCode(), ByteBlock.wrap(encmsg.getData())); oscarSession .getTransport() .sendMessage( oscarSession.getJIDWithHighestPriority(), oscarSession.getTransport().convertIDToJID(sn), imsg.getMessage()); } else if (cmd instanceof OfflineMsgDoneCmd) { request(new OfflineMsgIcqAckCmd(oscarSession.getUIN(), (int) oscarSession.nextIcqId())); } else if (cmd instanceof MetaShortInfoCmd) { // MetaShortInfoCmd msic = (MetaShortInfoCmd)cmd; // Log.debug("RECEIVED META SHORT INFO: "+msic); // oscarSession.updateRosterNickname(String.valueOf(msic.getUIN()), // msic.getNickname()); } else if (cmd instanceof BuddyAddedYouCmd) { BuddyAddedYouCmd bay = (BuddyAddedYouCmd) cmd; Presence p = new Presence(); p.setType(Presence.Type.subscribe); p.setTo(oscarSession.getJID()); p.setFrom(oscarSession.getTransport().convertIDToJID(bay.getUin())); oscarSession.getTransport().sendPacket(p); } else if (cmd instanceof BuddyAuthRequest) { BuddyAuthRequest bar = (BuddyAuthRequest) cmd; Presence p = new Presence(); p.setType(Presence.Type.subscribe); p.setTo(oscarSession.getJID()); p.setFrom(oscarSession.getTransport().convertIDToJID(bar.getScreenname())); oscarSession.getTransport().sendPacket(p); } else if (cmd instanceof AuthReplyCmd) { AuthReplyCmd ar = (AuthReplyCmd) cmd; if (ar.isAccepted()) { Presence p = new Presence(); p.setType(Presence.Type.subscribed); p.setTo(oscarSession.getJID()); p.setFrom(oscarSession.getTransport().convertIDToJID(ar.getSender())); oscarSession.getTransport().sendPacket(p); } else { Presence p = new Presence(); p.setType(Presence.Type.unsubscribed); p.setTo(oscarSession.getJID()); p.setFrom(oscarSession.getTransport().convertIDToJID(ar.getSender())); oscarSession.getTransport().sendPacket(p); } } else if (cmd instanceof AuthFutureCmd) { AuthFutureCmd af = (AuthFutureCmd) cmd; Presence p = new Presence(); p.setType(Presence.Type.subscribe); p.setTo(oscarSession.getJID()); p.setFrom(oscarSession.getTransport().convertIDToJID(af.getUin())); oscarSession.getTransport().sendPacket(p); } }